Example #1
0
 /**
  * Helper to quickly create a new asset
  *
  * @param integer $parentId
  * @param array $data
  * @return Asset
  */
 public static function create($parentId, $data = array())
 {
     $asset = new self();
     $asset->setParentId($parentId);
     foreach ($data as $key => $value) {
         $asset->setValue($key, $value);
     }
     $asset->save();
     // get concrete type of asset
     Zend_Registry::set("asset_" . $asset->getId(), null);
     $asset = self::getById($asset->getId());
     Zend_Registry::set("asset_" . $asset->getId(), $asset);
     return $asset;
 }
Example #2
0
 /**
  *
  * @param  array  $data
  * @return Folder
  */
 public static function create(array $data = array())
 {
     $defaults = array('id' => null, 'parent_id' => null, 'name' => null, 'url' => null, 'uuid' => null, 'data' => new IdentifiableDataContainer(array()));
     $data = array_merge($defaults, $data);
     $obj = new self();
     $obj->setId($data['id']);
     $obj->setParentId($data['parent_id']);
     $obj->setName($data['name']);
     $obj->setUrl($data['url']);
     $obj->setUuid($data['uuid']);
     $obj->setData($data['data']);
     return $obj;
 }
Example #3
0
 /**
  * @param CategoryEntity $category
  * @return Category
  */
 public static function createFromCategoryEntity(CategoryEntity $category)
 {
     $struct = new self();
     $struct->setId($category->getId());
     $struct->setName($category->getName());
     $struct->setPosition($category->getPosition());
     $struct->setParentId($category->getParentId());
     $path = $category->getPath();
     if ($path) {
         $path = ltrim($path, '|');
         $path = rtrim($path, '|');
         $path = explode('|', $path);
         $struct->setPath(array_reverse($path));
     }
     return $struct;
 }
Example #4
0
 /**
  * @param ShopEntity $shop
  * @return Shop
  */
 public static function createFromShopEntity(ShopEntity $shop)
 {
     $struct = new self();
     $struct->setId($shop->getId());
     $struct->setParentId($shop->getMain() ? $shop->getMain()->getId() : $shop->getId());
     $struct->setIsDefault($shop->getDefault());
     $struct->setName($shop->getName());
     $struct->setHost($shop->getHost());
     $struct->setPath($shop->getBasePath());
     $struct->setUrl($shop->getBaseUrl());
     $struct->setSecure($shop->getSecure());
     $struct->setSecureHost($shop->getSecureHost());
     $struct->setSecurePath($shop->getSecureBasePath());
     if ($shop->getCategory()) {
         $struct->setCategory(Category::createFromCategoryEntity($shop->getCategory()));
     }
     if ($shop->getFallback()) {
         $struct->setFallbackId($shop->getFallback()->getId());
     }
     return $struct;
 }