Example #1
0
 public function __construct(Engine_Package_Manager $manager, array $packages = array(), array $options = array())
 {
     // Set manager
     $this->_manager = $manager;
     // Prepare packages
     $data = array();
     $indexByGuid = array();
     foreach ($packages as $package) {
         if (!$package instanceof Engine_Package_Manifest) {
             throw new Engine_Package_Manager_Exception('Not a package');
         }
         $guid = $package->getGuid();
         $key = $package->getKey();
         $data[$key] = $package;
         if (!isset($indexByGuid[$key])) {
             $indexByGuid[$guid] = $key;
         } else {
             throw new Engine_Package_Manager_Exception('Does not support multiple versions of the same package');
         }
     }
     unset($package);
     unset($packages);
     $this->_indexByGuid = $indexByGuid;
     if (!isset($options['persistent'])) {
         $options['persistent'] = false;
     }
     parent::__construct($data, $this->_manager->getCache(), $options);
 }
Example #2
0
 public function __construct(Engine_Package_Manager $manager, array $operations = array(), $options = array())
 {
     // Set manager
     $this->_manager = $manager;
     // Prepare operations
     $data = array();
     $indexByGuid = array();
     foreach ($operations as $operation) {
         if (!$operation instanceof Engine_Package_Manager_Operation_Abstract) {
             throw new Engine_Package_Manager_Exception('Not an operation');
         }
         $operation->setManager($manager);
         $guid = $operation->getGuid();
         $key = $operation->getKey();
         $data[$key] = $operation;
         if (!isset($indexByGuid[$key])) {
             $indexByGuid[$guid] = $key;
         } else {
             throw new Engine_Package_Manager_Exception('Does not support multiple versions of the same package');
         }
     }
     unset($operation);
     unset($operations);
     $this->_indexByGuid = $indexByGuid;
     parent::__construct($data, $this->_manager->getCache(), $options);
 }