Ejemplo n.º 1
0
 /**
  * Create Data.
  *
  * Main method to kick this all off. Make a resource then pass it over, and use toArray()
  *
  * @param ResourceInterface $resource
  * @param string            $scopeIdentifier
  * @param Scope             $parentScopeInstance
  *
  * @return Scope
  */
 public function createData(ResourceInterface $resource, $scopeIdentifier = null, Scope $parentScopeInstance = null)
 {
     $scopeInstance = new Scope($this, $resource, $scopeIdentifier);
     // Update scope history
     if ($parentScopeInstance !== null) {
         // This will be the new children list of parents (parents parents, plus the parent)
         $scopeArray = $parentScopeInstance->getParentScopes();
         $scopeArray[] = $parentScopeInstance->getScopeIdentifier();
         $scopeInstance->setParentScopes($scopeArray);
     }
     return $scopeInstance;
 }
Ejemplo n.º 2
0
 public function testPushParentScope()
 {
     $manager = new Manager();
     $resource = new Item(array('name' => 'Larry Ullman'), function () {
     });
     $scope = new Scope($manager, $resource);
     $this->assertEquals(1, $scope->pushParentScope('book'));
     $this->assertEquals(2, $scope->pushParentScope('author'));
     $this->assertEquals(3, $scope->pushParentScope('profile'));
     $this->assertEquals(array('book', 'author', 'profile'), $scope->getParentScopes());
 }