ZF\Apigility\Admin\Model\AuthorizationEntity::addRestService PHP Method

addRestService() public method

public addRestService ( $serviceName, $entityOrCollection, array $privileges = null )
$privileges array
    public function addRestService($serviceName, $entityOrCollection, array $privileges = null)
    {
        if (!in_array($entityOrCollection, $this->allowedRestTypes)) {
            throw new Exception\InvalidArgumentException(sprintf('Invalid type "%s" provided for %s; must be one of "%s" or "%s"', $entityOrCollection, __METHOD__, self::TYPE_ENTITY, self::TYPE_COLLECTION));
        }
        $this->addRpcService($serviceName, sprintf('__%s__', $entityOrCollection), $privileges);
        return $this;
    }

Usage Example

 public function testAddingARestServiceWithoutHttpMethodsProvidesDefaults()
 {
     $entity = new AuthorizationEntity();
     $entity->addRestService('Foo\\V1\\Rest\\Session\\Controller', AuthorizationEntity::TYPE_ENTITY);
     $this->assertTrue($entity->has('Foo\\V1\\Rest\\Session\\Controller::__entity__'));
     $privileges = $entity->get('Foo\\V1\\Rest\\Session\\Controller::__entity__');
     $this->assertEquals(['GET' => false, 'POST' => false, 'PATCH' => false, 'PUT' => false, 'DELETE' => false], $privileges);
 }
All Usage Examples Of ZF\Apigility\Admin\Model\AuthorizationEntity::addRestService