Esempio n. 1
0
 /**
  * creates snippet for standalone object, ie. {{ $item }}
  *
  * @param $item BaseItem
  * @param bool $owner
  * @return string
  */
 public static function blade(BaseItem $item, $owner = false)
 {
     if ($owner && $item->owner) {
         return sprintf('{{ $%s->%s }}', $item->variable(), $item->owner->variable());
     }
     return sprintf('{{ $%s }}', $item->variable());
 }
Esempio n. 2
0
 /**
  * @covers Foote\Ginny\Map\BaseItem::__construct
  * @covers Foote\Ginny\Map\BaseItem::__toString
  * @covers Foote\Ginny\Map\BaseItem::__get
  * @covers Foote\Ginny\Map\BaseItem::single
  * @covers Foote\Ginny\Map\BaseItem::plural
  * @covers Foote\Ginny\Map\BaseItem::variable
  * @covers Foote\Ginny\Map\BaseItem::variables
  * @covers Foote\Ginny\Map\BaseItem::camel
  * @covers Foote\Ginny\Map\BaseItem::camels
  * @covers Foote\Ginny\Map\BaseItem::human
  * @covers Foote\Ginny\Map\BaseItem::title
  * @covers Foote\Ginny\Map\BaseItem::snake
  * @covers Foote\Ginny\Map\BaseItem::snakes
  * @covers Foote\Ginny\Map\BaseItem::low
  * @covers Foote\Ginny\Map\BaseItem::up
  * @covers Foote\Ginny\Map\BaseItem::getter
  * @covers Foote\Ginny\Map\BaseItem::getters
  * @covers Foote\Ginny\Map\BaseItem::setter
  * @covers Foote\Ginny\Map\BaseItem::setters
  * @covers Foote\Ginny\Map\BaseItem::adder
  * @covers Foote\Ginny\Map\BaseItem::remover
  * @covers Foote\Ginny\Map\BaseItem::update
  * @covers Foote\Ginny\Map\BaseItem::validate
  * @covers Foote\Ginny\Map\BaseItem::create
  * @covers Foote\Ginny\Map\BaseItem::dump
  */
 public function test()
 {
     $item = new BaseItem('BigThing');
     $this->assertEquals($item->name, 'BigThing');
     $this->assertEquals($item->__toString(), 'BigThing');
     $this->assertEquals($item->undefined_property, null);
     $this->assertEquals($item->single, 'BigThing');
     $this->assertEquals($item->plural, 'BigThings');
     $this->assertEquals($item->variable, 'bigThing');
     $this->assertEquals($item->variables, 'bigThings');
     $this->assertEquals($item->camel, 'BigThing');
     $this->assertEquals($item->camels, 'BigThings');
     $this->assertEquals($item->human, 'Big thing');
     $this->assertEquals($item->title, 'Big Thing');
     $this->assertEquals($item->snake, 'big_thing');
     $this->assertEquals($item->snakes, 'big_things');
     $this->assertEquals($item->low, 'bigthing');
     $this->assertEquals($item->up, 'BIGTHING');
     $this->assertEquals($item->getter, 'getBigThing');
     $this->assertEquals($item->getters, 'getBigThings');
     $this->assertEquals($item->setter, 'setBigThing');
     $this->assertEquals($item->setters, 'setBigThings');
     $this->assertEquals($item->adder, 'addBigThing');
     $this->assertEquals($item->remover, 'removeBigThing');
     $item2 = BaseItem::create('BigThing');
     $this->assertEquals($item, $item2);
     $item3 = BaseItem::create('BigThing', ['name' => 'OtherThing']);
     $this->assertEquals('OtherThing', $item3->name);
     //nothing happens here
     $item->update();
     $item->validate();
     $item->dump();
 }
Esempio n. 3
0
 function __construct($name, $params = [])
 {
     parent::__construct($name, $params);
     $this->prefix = $name;
     $this->bundles = new Collection();
     return $this;
 }
Esempio n. 4
0
 function __construct($name, $params = [])
 {
     parent::__construct($name, $params);
     $this->keys = new Collection();
     $this->models = new Collection();
     $this->models->set('owner', $this->owner);
     $this->owner->addAssociation($this);
     switch ($this->type) {
         case 'belongsTo':
             $this->models->set('child', $this->owner);
             $this->models->set('parent', $this->target);
             $this->addKey('local', $this->owner->fields->get($this->ownerKey));
             $this->addKey('parent', $this->target->fields->get($this->targetKey));
             $this->owner->fields->get($this->ownerKey)->parent = $this->target;
             break;
         case 'belongsToMany':
             $this->pivotOwnerBelongsTo = $this->pivot->associations->get($this->owner->name);
             $this->pivotTargetBelongsTo = $this->pivot->associations->get($this->target->name);
             $this->models->set('child', $this->owner);
             $this->models->set('parent', $this->target);
             $this->models->set('pivot', $this->pivot);
             $this->addKey('local', $this->owner->fields->get($this->ownerKey));
             $this->addKey('parent', $this->target->fields->get($this->targetKey));
             $this->addKey('pivot_local', $this->pivotOwnerBelongsTo->keys('local'));
             $this->addKey('pivot_parent', $this->pivotTargetBelongsTo->keys('local'));
             break;
         case 'hasMany':
             $this->models->set('child', $this->target);
             $this->models->set('parent', $this->owner);
             $this->addKey('local', $this->owner->fields->get($this->ownerKey));
             $this->addKey('foreign', $this->target->fields->get($this->targetKey));
             break;
         case 'hasOne':
             $this->models->set('child', $this->target);
             $this->models->set('parent', $this->owner);
             $this->addKey('local', $this->owner->fields->get($this->ownerKey));
             $this->addKey('foreign', $this->target->fields->get($this->targetKey));
             break;
     }
 }
Esempio n. 5
0
 function __construct($name, $params = [])
 {
     parent::__construct($name, $params);
     $this->models = new Collection();
 }
Esempio n. 6
0
 /**
  * @param string $name
  */
 function __construct($name, $params = [])
 {
     parent::__construct($name, $params);
     $this->fields = new Collection();
     $this->associations = new Collection();
 }