Beispiel #1
0
 public function testWriteAnnotations()
 {
     $tests = new Tests();
     $tests->data = 'test';
     Dao::write($tests, [Dao::only(['data'])]);
     Dao::delete($tests);
     $this->assume(__METHOD__, $tests->data, 'test+locbefore(data)+disbefore(data)+locafter(data)+disafter(data)');
 }
Beispiel #2
0
 /**
  * @param $object Framework\Logger
  */
 public function onLoggerStop(Framework\Logger $object)
 {
     if ($this->log_flag) {
         Dao::begin();
         foreach (Dao::search(['log' => Func::isNull()], Compiler_Log::class) as $logger) {
             /** @var $logger Compiler_Log */
             $logger->log = $object->log_entry;
             Dao::write($logger, [Dao::only(['log'])]);
         }
         $this->log_flag = false;
         Dao::commit();
     }
 }
Beispiel #3
0
 /**
  * To use this :
  * - Create your own writeSubClassNames() method
  * - Your method has no parameters
  * - Your method returns nothing
  * - Call return writeSub('sub_class_names', 'super_class_name') using your two properties names
  *
  * @param $sub   string sub property name ie 'sub_class_names'
  * @param $super string super property name ie 'super_class_name'
  */
 private function writeSub($sub, $super)
 {
     $written = [];
     // update $super_property into new $sub_properties
     foreach ($this->{$sub} as $sub) {
         if (!Dao::is($this, $sub->{$super})) {
             $sub->{$super} = $this;
             Dao::write($sub, [Dao::only($super)]);
         }
         $written[Dao::getObjectIdentifier($sub)] = true;
     }
     // empty $super_property from removed $sub_properties
     $subs = Dao::search([$super => $this], Link_Class::linkedClassNameOf($this));
     foreach ($subs as $sub) {
         if (!isset($written[Dao::getObjectIdentifier($sub)])) {
             $sub->{$super} = null;
             Dao::write($sub, [Dao::only($super)]);
         }
     }
 }