コード例 #1
0
ファイル: Installer.php プロジェクト: linuxwhy/tiki-1
 public function getInstallHandler(Tiki_Profile_Object $object)
 {
     $type = $object->getType();
     if (array_key_exists($type, $this->handlers)) {
         if ($this->allowedObjectTypes !== false && !in_array($type, $this->allowedObjectTypes)) {
             return null;
         }
         $class = $this->handlers[$type];
         if (class_exists($class)) {
             return new $class($object, $this->userData);
         }
     }
 }
コード例 #2
0
 private function getInstallHandler(Tiki_Profile_Object $object)
 {
     $type = $object->getType();
     if (array_key_exists($type, $this->handlers)) {
         $class = $this->handlers[$type];
         if (class_exists($class)) {
             return new $class($object);
         }
     }
 }
コード例 #3
0
 function getObjects()
 {
     if (!is_null($this->objects)) {
         return $this->objects;
     }
     $objects = array();
     if (array_key_exists('objects', $this->data)) {
         foreach ($this->data['objects'] as &$entry) {
             $o = new Tiki_Profile_Object($entry, $this);
             if ($o->isWellStructured()) {
                 $objects[] = $o;
             } else {
                 $str = '';
                 foreach ($entry as $k => $v) {
                     $str .= empty($str) ? '' : ', ';
                     $str .= "{$k}: {$v}";
                 }
                 $this->setFeedback(tra('Syntax error: ') . $str . "\n" . tra("Needs a 'type' and 'data' field"));
             }
         }
     }
     $classified = array();
     $names = array();
     // Order object creations to make sure all objects are created when needed
     // Circular dependencies get dicarded
     $counter = 0;
     $refs = array();
     while (!empty($objects)) {
         // Circular dependency found... give what we have
         if ($counter++ > count($objects) * 2) {
             $this->setFeedback(tra('Circular reference') . ': ' . implode(', ', array_unique($refs)));
             break;
         }
         $object = array_shift($objects);
         $refs = $object->getInternalReferences();
         $refs = array_diff($refs, $names);
         if (empty($refs)) {
             $counter = 0;
             $classified[] = $object;
             if ($object->getRef()) {
                 $names[] = $object->getRef();
             }
         } else {
             $objects[] = $object;
         }
     }
     $this->objects = $classified;
     return $this->objects;
 }
コード例 #4
0
 function getObjects()
 {
     if (!is_null($this->objects)) {
         return $this->objects;
     }
     $objects = array();
     if (array_key_exists('objects', $this->data)) {
         foreach ($this->data['objects'] as &$entry) {
             $o = new Tiki_Profile_Object($entry, $this);
             if ($o->isWellStructured()) {
                 $objects[] = $o;
             }
         }
     }
     $classified = array();
     $names = array();
     // Order object creations to make sure all objects are created when needed
     // Circular dependencies get dicarded
     $counter = 0;
     while (!empty($objects)) {
         // Circular dependency found... give what we have
         if ($counter++ > count($objects) * 2) {
             break;
         }
         $object = array_shift($objects);
         $refs = $object->getInternalReferences();
         $refs = array_diff($refs, $names);
         if (empty($refs)) {
             $counter = 0;
             $classified[] = $object;
             if ($object->getRef()) {
                 $names[] = $object->getRef();
             }
         } else {
             $objects[] = $object;
         }
     }
     $this->objects = $classified;
     return $this->objects;
 }