public function checkResource( $resource, $parent = null )
    {
        if ( null === $resource )
        {
            return null;
        }

        if ( $resource instanceof Acl\Resource\ResourceInterface )
        {
            $resource = $resource->getResourceId();
        }

        $acl = $this->getAcl();

        if ( ! $acl->hasResource( $resource ) )
        {
            if ( null === $parent )
            {
                $parent = $this->getParentId( $resource );
            }
            elseif ( $parent instanceof Acl\Resource\ResourceInterface )
            {
                $parent = $parent->getResourceId();
            }

            $parent = $this->checkResource( $parent );
            $acl->addResource( $resource, $parent );
        }

        return $resource;
    }