Sulu\Bundle\ContactBundle\Entity\Country::setName PHP Method

setName() public method

Set name.
public setName ( string $name ) : Country
$name string
return Country
    public function setName($name)
    {
        $this->name = $name;
        return $this;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     // force id = 1
     $metadata = $manager->getClassMetaData(get_class(new Country()));
     $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
     $i = 1;
     $file = dirname(__FILE__) . '/../countries.xml';
     $doc = new \DOMDocument();
     $doc->load($file);
     $xpath = new \DOMXpath($doc);
     $elements = $xpath->query('/Countries/Country');
     if (!is_null($elements)) {
         /** @var $element DOMNode */
         foreach ($elements as $element) {
             $country = new Country();
             $country->setId($i);
             $children = $element->childNodes;
             /** @var $child DOMNode */
             foreach ($children as $child) {
                 if (isset($child->nodeName)) {
                     if ($child->nodeName == 'Name') {
                         $country->setName($child->nodeValue);
                     }
                     if ($child->nodeName == 'Code') {
                         $country->setCode($child->nodeValue);
                     }
                 }
             }
             $manager->persist($country);
             ++$i;
         }
     }
     $manager->flush();
 }
All Usage Examples Of Sulu\Bundle\ContactBundle\Entity\Country::setName