Example #1
0
 public function __construct($object, &$request_data)
 {
     parent::__construct();
     $this->_object = $object;
     $this->_object_path = $this->get_object_path();
     $this->_request_data =& $request_data;
     $this->root_types = midcom_helper_reflector_tree::get_root_classes();
     if (array_key_exists('current_type', $this->_request_data)) {
         $this->expanded_root_types[] = $this->_request_data['current_type'];
     } else {
         if (isset($this->_object)) {
             $object = $this->_object;
             if (!empty($this->_object_path)) {
                 $object = midcom::get('dbfactory')->get_object_by_guid($this->_object_path[0]);
             }
             foreach ($this->root_types as $root_type) {
                 if (is_a($object, $root_type) || midcom_helper_reflector::is_same_class($root_type, $object->__midcom_class_name__)) {
                     $this->expanded_root_types[] = $root_type;
                     break;
                 }
             }
         }
     }
 }
Example #2
0
 /**
  * @dataProvider providerIs_same_class
  */
 public function testIs_same_class($classname1, $classname2, $result)
 {
     $this->assertEquals($result, midcom_helper_reflector::is_same_class($classname1, $classname2));
 }
Example #3
0
 private function _find_linking_property($new_type)
 {
     // Figure out the linking property
     $new_type_reflector = midcom_helper_reflector::get($new_type);
     $link_properties = $new_type_reflector->get_link_properties();
     $type_to_link_to = midcom_helper_reflector::class_rewrite(get_class($this->_object));
     foreach ($link_properties as $new_type_property => $link) {
         $linked_type = midcom_helper_reflector::class_rewrite($link['class']);
         if (midcom_helper_reflector::is_same_class($linked_type, $type_to_link_to) || $link['type'] == MGD_TYPE_GUID && is_null($link['class'])) {
             $parent_property = $link['target'];
             return array($new_type_property, $parent_property);
         }
     }
     return false;
 }
Example #4
0
 function _resolve_child_classes_links_back($property, $prospect_type, $schema_type)
 {
     if (empty($property)) {
         return false;
     }
     $ref = new midgard_reflection_property($prospect_type);
     $link_class = $ref->get_link_name($property);
     if (empty($link_class) && $ref->get_midgard_type($property) === MGD_TYPE_GUID) {
         return true;
     }
     if (midcom_helper_reflector::is_same_class($link_class, $schema_type)) {
         return true;
     }
     return false;
 }