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