/** * @param \Product\Entity\Product|Post $entity */ public function addEntityInfo($entity) { $this->writer->startElement('url'); $this->writer->writeElement('lastmod', date(\Datetime::ATOM, time())); $this->writer->startElement('image:image'); if ($entity instanceof Post) { $this->writer->writeElement('image:loc', "http://www.infolightingco.com/images/posts/" . $entity->getThumbnail()); $this->writer->writeElement('loc', "http://www.infolightingco.com/news/" . $entity->getUrl()); } else { $this->writer->writeElement('image:loc', "http://www.infolightingco.com/images/posts/" . $entity->getThumbnail()); $this->writer->writeElement('loc', "http://www.infolightingco.com/products/view/" . $entity->getProductNumber()); } $this->writer->endElement(); $this->writer->endElement(); }
public function createAction() { $form = new ProductForm(); $form->get('submit')->setValue('Create'); $request = $this->getRequest(); if ($request->isPost()) { $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_another'); $productEntity = new Product(); $product = new \Product\Model\Product(); $form->setInputFilter($product->getInputFilter()); $File = $this->params()->fromFiles('image'); $form->setData($request->getPost()); if ($form->isValid()) { $adapter = new \Zend\File\Transfer\Adapter\Http(); $this->saveImage($form, $adapter, $File); $tagsArray = explode(",", $form->getData()["tags"]); foreach ($tagsArray as $tag) { $entityTag = new Tags(); $entityTag->setName($tag); $productEntity->getIdTag()->add($entityTag); $em->persist($entityTag); } $productEntity->exchangeArray($form->getData()); $productEntity->setCreationdate(new \DateTime()); $productEntity->setImage($adapter->getFileName(null, false)); $em->persist($productEntity); $em->flush(); return $this->redirect()->toRoute('product'); } } return array('form' => $form); }
public function getServiceConfig() { return array('factories' => array('Product\\Entity\\Brand' => function ($sm) { $brand = new BrandEntity(); $brand->setTable(new BrandTable($sm->get('Zend\\Db\\Adapter\\Adapter'))); return $brand; }, 'Product\\Entity\\Category' => function ($sm) { $category = new CategoryEntity(); $category->setTable(new CategoryTable($sm->get('Zend\\Db\\Adapter\\Adapter'))); return $category; }, 'Product\\Entity\\Product' => function ($sm) { $entity = new ProductEntity(); $entity->setTable(new ProductTable($sm->get('Zend\\Db\\Adapter\\Adapter'))); return $entity; }, 'Product\\Table\\ProductTable' => function ($sm) { $adapter = $sm->get('Zend\\Db\\Adapter\\Adapter'); $productEntity = $sm->get('Product\\Entity\\Product'); $brandEntity = $sm->get('Product\\Entity\\Brand'); $productEntity->setBrandEntity($brandEntity); $categoryEntity = $sm->get('Product\\Entity\\Category'); $productEntity->setCategoryEntity($categoryEntity); $table = new ProductTable($adapter); $table->getResultSetPrototype()->setArrayObjectPrototype($productEntity); return $table; }, 'Product\\Table\\BrandTable' => function ($sm) { $adapter = $sm->get('Zend\\Db\\Adapter\\Adapter'); $entity = $sm->get('Product\\Entity\\Brand'); $table = new BrandTable($adapter); $table->getResultSetPrototype()->setArrayObjectPrototype($entity); return $table; }, 'Product\\Table\\CategoryTable' => function ($sm) { $adapter = $sm->get('Zend\\Db\\Adapter\\Adapter'); $entity = $sm->get('Product\\Entity\\Category'); $table = new CategoryTable($adapter); $table->getResultSetPrototype()->setArrayObjectPrototype($entity); return $table; })); }