Skip to content
This repository has been archived by the owner on Feb 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #17 from fightmaster/fix-of-fatal-errors
Browse files Browse the repository at this point in the history
Fixed fatal errors.
  • Loading branch information
igorgolovanov committed Nov 17, 2011
2 parents 4ad2367 + 41ccfbb commit 1e47c43
Show file tree
Hide file tree
Showing 13 changed files with 572 additions and 93 deletions.
2 changes: 1 addition & 1 deletion doctrine-mapping.xsd
Expand Up @@ -102,7 +102,7 @@
<xs:attribute name="identifier" type="xs:boolean" default="false" />
<xs:attribute name="id-generator" type="oxm:generator-strategy" use="optional" default="AUTO" />
<xs:attribute name="direct" type="xs:boolean" default="true" />
<xs:attribute name="nillable" type="xs:boolean" default="false" />
<xs:attribute name="nullable" type="xs:boolean" default="false" />
<xs:attribute name="required" type="xs:boolean" default="false" />
<xs:attribute name="collection" type="xs:boolean" default="false" />
<xs:attribute name="get-method" type="xs:NMTOKEN" />
Expand Down
8 changes: 6 additions & 2 deletions lib/Doctrine/OXM/Mapping/ClassMetadataFactory.php
Expand Up @@ -184,7 +184,6 @@ private function initialize()
public function getMetadataFor($className)
{
if ( ! isset($this->loadedMetadata[$className])) {
// print_r('loading class ' . $className . "\n");
$realClassName = $className;

// Check for namespace alias
Expand Down Expand Up @@ -334,13 +333,19 @@ protected function loadMetadata($name)

$class->setParentClasses($visited);



// Todo - ensure that root elements have an ID mapped

if ($this->evm->hasListeners(Events::loadClassMetadata)) {
$eventArgs = new \Doctrine\OXM\Event\LoadClassMetadataEventArgs($class, $this);
$this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs);
}

/**
* Firstly, we must save parsing object in the repository, then proceed to parsing of dependent objects.
* This guarantees the absence of infinite loops.
*/
$this->loadedMetadata[$className] = $class;
$this->completeMappingTypeValidation($className, $class);

Expand Down Expand Up @@ -377,7 +382,6 @@ private function completeMappingTypeValidation($className, ClassMetadataInfo $cl
if (!$this->hasMetadataFor($mapping['type']) && !$this->getMetadataFor($mapping['type'])) {
throw MappingException::fieldTypeNotFound($className, $fieldName, $mapping['type']);
}

// Mapped classes must have binding node type XML_ELEMENT
if ($mapping['node'] !== ClassMetadataInfo::XML_ELEMENT) {
throw MappingException::customTypeWithoutNodeElement($className, $fieldName);
Expand Down
14 changes: 14 additions & 0 deletions lib/Doctrine/OXM/Marshaller/Helper/WriterHelper.php
Expand Up @@ -84,13 +84,27 @@ public function startElement($name, $prefix = null, $url = null)

public function writeElement($name, $value, $prefix = null, $url = null)
{
$result = preg_grep('{[\&,\<,\>,\#]}',array($value));
if(!empty($result)) {
$this->writeCdataElement($name, $value, $prefix, $url);
return;
}

if ($prefix !== null) {
$this->cursor->writeElementNs($prefix, $name, $url, $value);
} else {
$this->cursor->writeElement($name, $value);
}
}

public function writeCdataElement($name, $value, $prefix = null, $url = null)
{
$this->startElement($name, $prefix, $url);
//A CDATA section cannot contain the string "]]>" and therefore it is not possible for a CDATA section to contain nested CDATA sections.
$this->cursor->writeCdata(preg_replace('/]]>/', ']]]]><![CDATA[>', $value));
$this->endElement();
}

public function writeNamespace($url, $prefix = null)
{
$attributeName = 'xmlns';
Expand Down

0 comments on commit 1e47c43

Please sign in to comment.