Esempio n. 1
0
 /**
  * @throws \Exception
  */
 protected function getApiVersion()
 {
     $version = 'v2';
     if ($this->parent instanceof Scope && $this->parent->getDunglasResource() instanceof DunglasResource) {
         $version = $this->parent->getDunglasResource()->getVersion();
     }
     return $version;
 }
Esempio n. 2
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 ApiScope($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);
         $scopeInstance->setParent($parentScopeInstance);
     }
     return $scopeInstance;
 }