Knp\Bundle\KnpBundlesBundle\Entity\Keyword::setValue PHP Method

setValue() public method

public setValue ( $value )
    public function setValue($value)
    {
        $this->value = $value;
        $this->setSlug(preg_replace('/[^a-z0-9_\\s-]/', '', preg_replace("/[\\s_]/", "-", strtolower(trim($value)))));
    }

Usage Example

Beispiel #1
0
 /**
  * @Given /^the bundles have following keywords:$/
  */
 public function theBundlesHaveFollowingKeywords(TableNode $table)
 {
     $entityManager = $this->getEntityManager();
     $repository = $entityManager->getRepository('Knp\\Bundle\\KnpBundlesBundle\\Entity\\Keyword');
     foreach ($table->getHash() as $row) {
         if (isset($this->bundles[$row['bundle']])) {
             $bundle = $this->bundles[$row['bundle']];
             $keyword = $repository->findOneBy(array('value' => $row['keyword']));
             if (!$keyword) {
                 $keyword = new Entity\Keyword();
                 $keyword->setValue($row['keyword']);
             }
             $bundle->addKeyword($keyword);
             $entityManager->persist($bundle);
         }
     }
     $entityManager->flush();
 }
All Usage Examples Of Knp\Bundle\KnpBundlesBundle\Entity\Keyword::setValue