/** * Load data fixtures with the passed EntityManager * * @param ObjectManager|DocumentManager $manager */ public function load(ObjectManager $manager) { $contentParent = $manager->find(null, '/cms/content'); $routeParent = $manager->find(null, '/cms/routes/en/services'); $menuBase = $manager->find(null, '/cms/menu/footer'); $content = new DemoSeoContent(); $content->setParentDocument($contentParent); $content->setName('seo-service'); $content->setTitle('SEO Service'); $content->setBody('A page about SEO service'); $metaData = new SeoMetadata(); $metaData->setMetaDescription('Description in Metadata'); $content->setSeoMetadata($metaData); $manager->persist($content); $manager->bindTranslation($content, 'en'); $contentRoute = new Route(); $contentRoute->setParentDocument($routeParent); $contentRoute->setName('seo-service'); $contentRoute->setContent($content); $manager->persist($contentRoute); $menuNode = new MenuNode(); $menuNode->setParentDocument($menuBase); $menuNode->setName('seo-service'); $menuNode->setLabel('SEO Services'); $menuNode->setContent($content); $manager->persist($menuNode); $manager->flush(); }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $session = $manager->getPhpcrSession(); $basepath = $this->container->getParameter('cmf_routing.dynamic.persistence.phpcr.route_basepath'); NodeHelper::createPath($session, $basepath); $routeRoot = $manager->find(null, $basepath); $basepath = $this->container->getParameter('cmf_content.persistence.phpcr.content_basepath'); NodeHelper::createPath($session, $basepath); $parent = $manager->find(null, $basepath); $repository = $this->container->get('sylius.repository.static_content'); $routeRepository = $this->container->get('sylius.repository.route'); // Terms of service. $route = $routeRepository->createNew(); $route->setPosition($routeRoot, 'terms-of-service'); $manager->persist($route); $content = $repository->createNew(); $content->setTitle('Terms of Service'); $content->setBody($this->faker->text(350)); $content->addRoute($route); $content->setParent($parent); $content->setName('terms-of-service'); $manager->persist($content); // Contact. $route = $routeRepository->createNew(); $route->setPosition($routeRoot, 'about'); $manager->persist($route); $content = $repository->createNew(); $content->setTitle('About us'); $content->setBody($this->faker->text(300)); $content->addRoute($route); $content->setParent($parent); $content->setName('about-us'); $manager->persist($content); $manager->flush(); }
/** * {@inheritdoc} */ public function createNew() { /** @var Route $route */ $route = $this->decoratedFactory->createNew(); $route->setParentDocument($this->documentManager->find(null, $this->routeParentPath)); return $route; }
/** * {@inheritdoc} */ public function createNew() { /** @var StaticContent $staticContent */ $staticContent = $this->decoratedFactory->createNew(); $staticContent->setParentDocument($this->documentManager->find(null, $this->staticContentParentPath)); return $staticContent; }
private function verifyBrands() { for ($i = 1; $i <= 10; ++$i) { /* @var $brand \Hautelook\AliceBundle\Tests\SymfonyApp\TestBundle\Entity\Brand */ $this->doctrineManager->find('Hautelook\\AliceBundle\\Tests\\SymfonyApp\\TestBundle\\Entity\\Brand', $i); } }
/** * Load data fixtures with the passed EntityManager * * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $numOfertas = 5; for ($i = 0; $i < $numOfertas; $i++) { $oferta = new Oferta(); $oferta->setNombre("Oferta " . $i); $oferta->setDescripcion("Descripción de la oferta " . $i); $oferta->setCondiciones("Condiciones de la oferta " . $i); $oferta->setFechaPublicacion(new \DateTime(date('Y-m-d H:i:s'))); $oferta->setFechaExpiracion(new \DateTime(date('Y-m-d H:i:s', strtotime('+1 years')))); if ($i % 2) { $oferta->setCiudad($manager->find('CiudadBundle:Ciudad', 1)); } else { $oferta->setCiudad($manager->find('CiudadBundle:Ciudad', 2)); } $oferta->setTienda($manager->find('TiendaBundle:Tienda', 1)); $oferta->setRutaFoto(null); $oferta->setPrecio(19.99); $oferta->setDescuento(0); $oferta->setUmbral(100); $oferta->setCompras(0); $oferta->setRevisada(1); $manager->persist($oferta); } $manager->flush(); }
/** * Loads the user for the given username. * * This method must throw UsernameNotFoundException if the user is not * found. * * @param string $username The username * * @return UserInterface * * @see UsernameNotFoundException * * @throws UsernameNotFoundException if the user is not found * */ public function loadUserByUsername($username) { if (!($user = $this->manager->find(null, sprintf('/users/%s', $username)))) { throw new UsernameNotFoundException(sprintf('User "%s" not found', $username)); } return $user; }
public function load(ObjectManager $manager) { NodeHelper::createPath($manager->getPhpcrSession(), '/test'); NodeHelper::createPath($manager->getPhpcrSession(), '/test/content'); NodeHelper::createPath($manager->getPhpcrSession(), '/test/routes/content'); $contentRoot = $manager->find(null, '/test/content'); $routeRoot = $manager->find(null, '/test/routes/content'); $content = new SeoAwareContent(); $content->setName('content-1'); $content->setTitle('Content 1'); $content->setBody('Content 1'); $content->setParentDocument($contentRoot); $metadata = new SeoMetadata(); $metadata->setTitle('Title content 1'); $metadata->setMetaDescription('Description of content 1.'); $metadata->setMetaKeywords('content1, content'); $metadata->setOriginalUrl('/to/original'); $content->setSeoMetadata($metadata); $manager->persist($content); $route = new Route(); $route->setPosition($routeRoot, 'content-1'); $route->setContent($content); $route->setDefault('_controller', 'Symfony\\Cmf\\Bundle\\SeoBundle\\Tests\\Resources\\Controller\\TestController::indexAction'); $manager->persist($route); $manager->persist($route); $manager->flush(); }
/** * @param object $object * @param string $fieldName * @param BaseControl $control * @param IClassMetadata $classMetadata * @throws \NForms\Exceptions\UnexpectedTypeException * @return bool */ public function save($object, $fieldName, BaseControl $control, IClassMetadata $classMetadata) { if ($control->isOmitted() || $control->isDisabled()) { return TRUE; } $value = $control->getValue(); if ($classMetadata->hasAssociation($fieldName) && $value !== NULL) { if ($classMetadata->isSingleValuedAssociation($fieldName)) { $value = $this->objectManager->find($classMetadata->getAssociationTargetClass($fieldName), $value); } else { if (!is_array($value) && (!$value instanceof \ArrayAccess || !$value instanceof \Iterator)) { throw new UnexpectedTypeException("In mapping association {$classMetadata->getClass()}::\${$fieldName} - expected array or ArrayAccess and Iterator instance, given " . get_class($value) . "."); } $collection = array(); foreach ($value as $id) { $collection[] = $this->objectManager->find($classMetadata->getAssociationTargetClass($fieldName), $id); } $value = $collection; } } if ($classMetadata->hasAssociation($fieldName)) { $classMetadata->setAssociationValue($object, $fieldName, $value); } else { if ($control instanceof Nette\Forms\Controls\TextBase && $value === '') { $value = NULL; } $classMetadata->setFieldValue($object, $fieldName, $value); } return TRUE; }
/** * {@inheritdoc} */ public function createWithCode() { $organization = $this->decoratedFactory->createWithCode(); if ($organization instanceof HierarchyInterface) { $organization->setParentDocument($this->documentManager->find(null, $this->rootPath)); } return $organization; }
/** * Get an attribute option or throw an exception * * @param integer $id * * @throws EntityNotFoundException * * @return AttributeInterface */ public function getAttributeOption($id) { $attribute = $this->objectManager->find($this->getAttributeOptionClass(), $id); if (null === $attribute) { throw new EntityNotFoundException(); } return $attribute; }
/** * Load the Document * * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $description = new Description(); $description->setType($manager->find("Project\\Entity\\Idea\\DescriptionType", 1)); $description->setIdea($manager->find("Project\\Entity\\Idea\\Idea", 1)); $description->setDescription('This is the inital description'); $manager->persist($description); $manager->flush(); }
public function load(ObjectManager $manager) { NodeHelper::createPath($manager->getPhpcrSession(), '/test/menus'); NodeHelper::createPath($manager->getPhpcrSession(), '/test/routes/contents'); $this->menuRoot = $manager->find(null, '/test/menus'); $this->routeRoot = $manager->find(null, '/test/routes'); $this->loadMenu($manager); $manager->flush(); }
/** * Load the Project * * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $projectLogo = new Logo(); $projectLogo->setContentType($manager->find("General\\Entity\\ContentType", 1)); $projectLogo->setLogo(file_get_contents(__DIR__ . '/../../assets/img/project_logo.jpg')); $projectLogo->setHires(file_get_contents(__DIR__ . '/../../assets/img/project_logo.jpg')); $projectLogo->setProject($manager->find("Project\\Entity\\Project", 1)); $manager->persist($projectLogo); $manager->flush(); }
public function load(ObjectManager $manager) { if ($manager->find('Api\\Camera\\Entity\\Camera', Camera::STATE_OFF) or $manager->find('Api\\Camera\\Entity\\Camera', Camera::STATE_ON)) { return; } $camera = new Camera(Camera::STATE_OFF); $manager->persist($camera); $manager->flush(); echo __CLASS__, "\n"; }
/** * Load the Project * * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $rationale = new Rationale(); $rationale->setCountry($manager->find("General\\Entity\\Country", 1)); $rationale->setContact($manager->find("Contact\\Entity\\Contact", 1)); $rationale->setProject($manager->find("Project\\Entity\\Project", 1)); $rationale->setRationale('This is the rationale'); $manager->persist($rationale); $manager->flush(); }
/** * @param mixed $id * * @throws \Symfony\Component\Form\Exception\TransformationFailedException * * @return mixed|object */ public function reverseTransform($id) { if (!$id) { return null; } $entity = $this->om->find($this->entityClass, $id); if (null === $entity) { throw new TransformationFailedException(sprintf('A %s with id "%s" does not exist!', $this->entityType, $id)); } return $entity; }
/** * {@inheritdoc} */ public function reverseTransform($id) { if ($id) { $entity = $this->manager->find($this->class, $id); if (is_null($entity)) { throw new TransformationFailedException(); } return $entity; } return null; }
/** * @param BulkEvent $e * * @return object * @throws */ protected function loadEntity(BulkEvent $e) { $meta = $this->objectManager->getClassMetadata($this->className); $identifier = current($meta->getIdentifierFieldNames()); $params = $e->getParams(); $id = isset($params[$identifier]) ? $params[$identifier] : 0; $entity = $this->objectManager->find($this->className, $id); if (!$entity) { throw new \RuntimeException('Entity with id ' . $id . ' was not found'); } return $entity; }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { $encoder = new BCryptPasswordEncoder(10); $user = new User(); $user->setEmail('*****@*****.**'); $user->setPassword($encoder->encodePassword('nhy6&UJM', null)); $user->setEnabled(1); $user->setRoles('ROLE_USER'); $user->setCreated(new \Datetime()); $manager->persist($user); $manager->flush(); $currencyDollar = new Currency(); $currencyDollar->setName('United States dollar'); $currencyDollar->setCode('USD'); $currencyDollar->setSymbol('$'); $manager->persist($currencyDollar); $manager->flush(); $currencyEuro = new Currency(); $currencyEuro->setName('Euro'); $currencyEuro->setCode('EUR'); $currencyEuro->setSymbol('€'); $manager->persist($currencyEuro); $manager->flush(); $currencySol = new Currency(); $currencySol->setName('Peruvian Nuevo Sol'); $currencySol->setCode('PEN'); $currencySol->setSymbol('S/.'); $manager->persist($currencySol); $manager->flush(); $account1 = new Account(); $account1->setOwner($user); $account1->setName('Checking'); $account1->setCurrency($currencyDollar); $account1->addTransaction(10000, 'Initial Deposit', new \DateTime()); $account1->addTransaction(2500, 'July Paycheck', new \DateTime()); $manager->persist($account1); $manager->flush(); $accId = $account1->getId(); $acc1 = $manager->find('Pfmgr\\Entity\\Account', $accId); $acc2 = $manager->find('Pfmgr\\Entity\\Account', $accId); $acc1->addTransaction(-1650, 'Rent', new \DateTime()); $acc2->addTransaction(-845.45, 'Audi A8 Payment', new \DateTime()); $manager->persist($acc1); $manager->persist($acc2); $manager->flush(); $account2 = new Account(); $account2->setOwner($user); $account2->setName('Checking'); $account2->setCurrency($currencyEuro); $manager->persist($account2); $manager->flush(); }
/** * Load the Gender * * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $country = $manager->find("General\\Entity\\Country", 1); $contact = $manager->find("Contact\\Entity\\Contact", 1); $funder = new \Program\Entity\Funder(); $funder->setContact($contact); $funder->setCountry($country); $funder->setInfoOffice('This is the info of the office'); $funder->setInfoPublic('This is the info of the public'); $funder->setShowOnWebsite(\Program\Entity\Funder::SHOW_ON_WEBSITE); $manager->persist($funder); $manager->flush(); }
/** * Load the Image * * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $image = new Image(); $image->setContentType($manager->find("General\\Entity\\ContentType", 1)); $image->setSize(1000); $image->setImage('This is the test-image'); $image->setIdea($manager->find("Project\\Entity\\Idea\\Idea", 1)); $imageObject = new ImageObject(); $imageObject->setObject(file_get_contents(__DIR__ . '/../../assets/img/idea_image.jpg')); $imageObject->setImage($image); $manager->persist($imageObject); $manager->flush(); }
/** * {@inheritDoc} */ public function find($path) { $image = $this->manager->find($this->class, $this->mapPathToId($path)); if (!$image) { // try to find the image without extension $info = pathinfo($path); $name = $info['dirname'] . '/' . $info['filename']; $image = $this->manager->find($this->class, $this->mapPathToId($name)); } if (!$image) { throw new NotLoadableException(sprintf('Source image was not found with id "%s"', $path)); } return stream_get_contents($this->getStreamFromImage($image)); }
/** * Load the Project * * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $invite = new Invite(); $invite->setContact($manager->find("Contact\\Entity\\Contact", 1)); $dateExpire = new \DateTime(); $dateExpire->add(new \DateInterval('P3M')); $invite->setDateExpire($dateExpire); $invite->setDeeplink($manager->find("Deeplink\\Entity\\Deeplink", 1)); $invite->setProject($manager->find("Project\\Entity\\Project", 1)); $invite->setInviteContact([$manager->find("Contact\\Entity\\Contact", 1)]); $invite->setInvite('ABCDEF'); $manager->persist($invite); $manager->flush(); }
/** * Load the Document * * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $document = new Document(); $document->setContentType($manager->find("General\\Entity\\ContentType", 1)); $document->setSize(1000); $document->setDocument('This is the test-document'); $document->setFilename('idea_document.pdf'); $document->setIdea($manager->find("Project\\Entity\\Idea\\Idea", 1)); $documentObject = new DocumentObject(); $documentObject->setObject(file_get_contents(__DIR__ . '/../../assets/doc/idea_document.pdf')); $documentObject->setDocument($document); $manager->persist($documentObject); $manager->flush(); }
/** * Load data fixtures with the passed EntityManager * * @param ObjectManager|DocumentManager $manager */ public function load(ObjectManager $manager) { $contentParent = $manager->find(null, '/cms/content'); $routeParent = $manager->find(null, '/cms/routes'); $menuBase = $manager->find(null, '/cms/menu'); $enRoute = new Route(); $enRoute->setPosition($routeParent, 'en'); $manager->persist($enRoute); $deRoute = new Route(); $deRoute->setPosition($routeParent, 'de'); $manager->persist($deRoute); $enServiceRoute = new Route(); $enServiceRoute->setPosition($enRoute, 'services'); $manager->persist($enServiceRoute); $deServiceRoute = new Route(); $deServiceRoute->setPosition($deRoute, 'dienstleistungen'); $manager->persist($deServiceRoute); $content = new StaticContent(); $content->setParentDocument($contentParent); $content->setName('symfony-service'); $manager->persist($content); $content->setTitle('Symfony Service'); $content->setBody('A page about Symfony service'); $manager->bindTranslation($content, 'en'); $contentRoute = new Route(); $contentRoute->setPosition($enServiceRoute, 'symfony-service'); $contentRoute->setContent($content); $manager->persist($contentRoute); $content->setTitle('Symfony Dienstleistungen'); $content->setBody('Eine Seite über Symfony Dienstleistungen'); $manager->bindTranslation($content, 'de'); $contentRoute = new Route(); $contentRoute->setPosition($deServiceRoute, 'symfony-dienstleistungen'); $contentRoute->setContent($content); $manager->persist($contentRoute); $menu = new Menu(); $menu->setPosition($menuBase, 'footer'); $manager->persist($menu); $menuNode = new MenuNode(); $menuNode->setParentDocument($menu); $menuNode->setContent($content); $menuNode->setName('symfony-service'); $manager->persist($menuNode); $menuNode->setLabel('Symfony Services'); $manager->bindTranslation($menuNode, 'en'); $menuNode->setLabel('Symfony Dienstleistungen'); $manager->bindTranslation($menuNode, 'de'); $manager->flush(); }
/** * Load the Document * * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $document = new Document(); $document->setContentType($manager->find("General\\Entity\\ContentType", 2)); $document->setSize(1000); $document->setDocument('This is the testdocument for the merge'); $document->setContact($manager->find("Contact\\Entity\\Contact", 1)); $document->setProject($manager->find("Project\\Entity\\Project", 1)); $document->setType($manager->find("Project\\Entity\\Document\\Type", 1)); $documentObject = new Object(); $documentObject->setObject(file_get_contents(__DIR__ . '/../../assets/doc/ITEA3_PO_Annex_template_Call1.docx')); $documentObject->setDocument($document); $manager->persist($documentObject); $manager->flush(); }
/** * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $data = []; // fixture was not versioned before // logic is following: // if version is null then it's first installation - load all statuses // if version is 0.0 then it's non-version fixture installed, load only new statuses if (!$this->version) { $data = array_merge($this->dataV0, $this->dataV1); } elseif ($this->version === '0.0') { $data = $this->dataV1; } elseif ($this->version === '1.0') { // remove not needed status from version 1.0 $converted = $manager->find('OroCRM\\Bundle\\MagentoBundle\\Entity\\CartStatus', 'converted'); if ($converted) { $manager->remove($converted); } } foreach ($data as $name => $label) { $method = new CartStatus($name); $method->setLabel($label); $manager->persist($method); } $manager->flush(); }
public function load(ObjectManager $manager) { $base = $manager->find(null, '/test/page'); $page = new Page(); $page->setName('homepage'); $page->setTitle('Homepage'); $page->setLabel('Homepage'); $page->setPublishable(true); $page->setAddLocalePattern(true); $page->setParent($base); $page->setBody($this->getContent('homepage.html')); $manager->persist($page); $page = new Page(); $page->setName('french-page'); $page->setTitle('French Page'); $page->setLabel('French Page'); $page->setPublishable(true); $page->setAddLocalePattern(true); $page->setLocale('fr'); $page->setBody($this->getContent('french-page.html')); $page->setParent($base); $manager->persist($page); $page = new Page(); $page->setName('no-locale-prefix'); $page->setTitle('No Locale Prefix'); $page->setLabel('No Locale Prefix'); $page->setPublishable(true); $page->setParent($base); $page->setBody($this->getContent('no-locale-prefix.html')); $page->setParent($base); $manager->persist($page); $manager->flush(); }
/** * {@inheritdoc} */ public function getImageUrl($image = null, $options = array(), $default = null) { if (is_string($options)) { $wh = null; // numeric only if (preg_match('/^([0-9]+)$/', $options)) { $wh = $options . 'x' . $options; // numeric x numeric } elseif (preg_match('/^([0-9]+)x([0-9]+)$/', $options)) { $wh = $options; } else { // nothing } $options = array('imagine_filter' => $this->filterName, 'runtime_config' => array('thumbnail' => array("size" => explode('x', $wh), "mode" => 'inset'))); if (null !== $wh && null === $default) { $default = 'https://placehold.it/' . $wh . '.jpg'; } } if (null === $image) { return $default; } if ($image instanceof ImageInterface) { $media = $image->getMedia(); // small buggy fix when form was interuted by error // object was not continue to `postload` of \Sylius\Bundle\MediaBundle\EventListener\ImageMediaReferenceListener if (null === $media && $this->documentManager) { if ($media = $this->documentManager->find(null, $image->getMediaId())) { $image->setMedia($media); } } } else { $media = $image; } return $media ? $this->displayUrl($media, $options) : $default; }