Returns bank-backend determined by given id.
This method returns backend if and only if backend with given id blongs to main tenant
else it throws not found exception

@param Pluf_HTTP_Request $request
@param array $match
@param array $p
427926
public function get($request, $match, $p)
    {
        $backend = parent::getObject($request, $match, $p);
        if ($backend->tenant !== Tenant_Shortcuts_GetMainTenant()->id) {
            throw new Pluf_HTTP_Error404("Object not found (" . $p['model'] . "," . $backend->id . ")");
        }
        return $backend;
    }
1003623
function create ($request, $match)
    {
        $location = Geo_Shortcuts_GetLocationOr404($match[1]);
        $vote = $location->getUserVote($request->tenant, $request->user);
        $extra = array(
                'user' => $request->user,
                'tenant' => $request->tenant,
                'location' => $location,
                'vote' => $vote
        );
        $form = new Geo_Form_Vote(
                array_merge($request->REQUEST, $request->FILES), $extra);
        $old = $vote;
        if ($vote === null) {
            $vote = $form->save();
//             $old = new SaaSKM_Vote();
//             $old->vote_value = ! $vote->vote_value;
//             User_Shortcuts_UpdateLeveFor($request, "jahanjoo_location_like");
        } else {
            $vote = $form->update();
        }
        
        if ($old->vote_value != $vote->vote_value) {
//             User_Shortcuts_UpdateLeveFor($location->get_reporter(), 
//                     "jahanjoo_location_like", $vote->like);
        }
        return new Pluf_HTTP_Response_Json($vote);
    }
669201
private function internalGet($request, $match){
        if ($request->user->hasPerm('tenant.owner')) {
            $sql = new Pluf_SQL('`key`=%s', array(
                $match['key']
            ));
        } else {
            $sql = new Pluf_SQL('`key`=%s AND `mode`=%s', array(
                $match['key'],
                Tenant_Setting::MOD_PUBLIC
            ));
        }
        $model = new Tenant_Setting();
        $model = $model->getOne(array(
            'filter' => $sql->gen()
        ));
        return $model;
    }
149549
public function match(RequestInterface $request, $pathOffset = 0)
    {
        if (!$request instanceof Request) {
            return null;
        }

        $pageUrl = substr($request->getUri()->getPath(), $pathOffset);

        $type = $this->getPageType();

        $pageParams = $this->parseUrl($pageUrl);

        if (empty($pageParams)) {
            return null;
        }

        try {
            $page = $this->getPage($pageParams['pageName'], $type);
        } catch (\Exception $e) {
            return null;
        }

        if (empty($page)) {
            return false;
        }

        $cms_params = array(
            'page' => $page,
            'controller' => $this->getController($type),
            'action' => $this->getAction($type),
            'revision' => $pageParams['revision']
        );

        return new RouteMatch($cms_params, strlen($pageUrl));
    }
682460
public static function get($request, $match)
    {
        $group = Pluf_Shortcuts_GetObjectOr404('User_Group', $match['group_id']);
        $role = new User_Role();
        $roles = $role->getList(array(
            'view' => 'join_group',
            'filter' => array(
                'user_group_id=' . $group->id
            )
        ));
        if ($roles->count() == 0) {
            throw new Pluf_Exception_DoesNotExist('Group has not such role');
        }
        return $roles[0];
    }
482443
public static function create($request, $match)
    {
        // Create account
        $extra = array();
        $data = array_merge($request->REQUEST, $request->FILES);
        // $form = new User_Form_User($data, $extra);
        // $cuser = $form->save();
        $usr = User_Account::getUser($data['login']);
        if ($usr) {
            throw new Pluf_Exception('Username is existed already.', 400);
        }
        if (! ($request->user->hasPerm('tenant.owner') || $request->user->hasPerm('user.manager')) 
                || ! array_key_exists('is_active', $data)) {
            $account_active = false;
            if (class_exists('Tenant_Service')) {
                $account_active = Tenant_Service::setting('Module.User.account_auto_activate', false);
            }else{                
                $account_active = Pluf::f('user_account_auto_activate', false);
            }
            $data['is_active'] = $account_active;
        }
        $form = new User_Form_Account($data, $extra);
        $cuser = $form->save();
        // Create credential
        $credit = new User_Credential();
        $credit->setFromFormData(array(
            'account_id' => $cuser->id
        ));
        $credit->setPassword($data['password']);
        $success = $credit->create();
        if (! $success) {
            throw new Pluf_Exception('An internal error is occured while create credential');
        }
        if (! Pluf::f('user_account_auto_activation', false)) {
            // TODO: hadi, 1397-05-26: send mail to activate account by user
        }
        // Return response
        return $cuser;
    }
947592
public static function delete($request, $match)
    {
        // Check access
        if(isset($match['userId'])){
            $user = Pluf_Shortcuts_GetObjectOr404('User_Account', $match['userId']);
        }else{
            $user = $request->user;
        }
        $profile = null;
        if (array_key_exists('profileId', $match)) {
            $profile = Pluf_Shortcuts_GetObjectOr404('User_Profile', $match['profileId']);
            if($profile->account_id !== $user->id){
                throw new Pluf_HTTP_Error404('Profile is not blong to given user');
            }
        }else{
            $profile = self::getProfileOfUser($user);
            if ($profile === null) {
                return new User_Profile();
            }
        }
        $profile->delete();
        return $profile;
    }
37003
function match(RequestInterface $request)
    {
        if ($preReq = $this->getPreparator()) {
            $request = $preReq->withRequestOnMatch($request);

            if (! $request instanceof RequestInterface )
                throw new \RuntimeException(sprintf(
                    'Missing RequestInterface While Preparing Request Object Through (%s).'
                    , \Poirot\Std\flatten($preReq)
                ));
        }


        ## match against connected routers if exists
        if (empty($this->routesAdd))
            return false;

        # build queue list for routers to match:

        # match routes:
        $routeMatch = false;
        foreach($this->_priorityQueue() as $route) {
            /** @var iRoute $r */
            $r = $route;
            if ($routeMatch = $r->match($request)) break;
        }

        ## if route match merge stack default params with match route
        /** @var iRoute $routeMatch */
        if ($routeMatch) {
            # $routeMatch = clone $routeMatch; // this can be skipped because use of match on each route
            \Poirot\Router\mergeParamsIntoRouter($routeMatch, $this->params());
        }

        return $routeMatch;
    }
1060422
private function match(InternalRequestInterface $request)
    {
        return !$this->hasMatcher()
            || (is_string($this->matcher) && preg_match($this->matcher, (string) $request->getUri()))
            || (is_callable($this->matcher) && call_user_func($this->matcher, $request));
    }
1116210
def get_match(self, match_id):
        """"""
        return self._make_req(endpoints.MATCH, dict(
            k=self.key,
            mp=match_id), Match)
223970
public function create($request, $match)
    {
        // initial content data
        $extra = array(
            'user' => $request->user,
            'model' => new CMS_Content()
        );

        // Create content and get its ID
        $form = new CMS_Form_ContentCreate($request->REQUEST, $extra);

        // Upload content file and extract information about it (by updating
        // content)
        $extra['model'] = $form->save();
        $form = new CMS_Form_ContentUpdate(array_merge($request->REQUEST, $request->FILES), $extra);
        try {
            $content = $form->save();
        } catch (Pluf_Exception $e) {
            $content = $extra['model'];
            $content->delete();
            throw $e;
        }
        return $content;
    }
1103251
public function update($request, $match)
    {
        // تعیین داده‌ها
        $content = Pluf_Shortcuts_GetObjectOr404('CMS_Content', $match['modelId']);
        // بررسی دسترسی‌ها
        if (! CMS_Precondition::isAuthor($request)) {
            throw new Pluf_Exception_PermissionDenied('You are not an author');
        }
        if (! CMS_Precondition::isEditor($request) && $request->user->id !== $content->author_id) {
            throw new Pluf_Exception_PermissionDenied('You can not change content created by another author');
        }
        return parent::updateObject($request, $match, array(
            'model' => 'CMS_Content'
        ));
    }
227853
public function defaultSpaRobotsTxt($request, $match)
    {
        $name = Tenant_Service::setting('spa.default', 'not-found');
        $spa = Tenant_SPA::getSpaByName($name);
        if (! isset($spa)) {
            $spa = Tenant_SpaService::getNotfoundSpa();
        }
        $resourcePath = $spa->getResourcePath('robots.txt');
        $host = ($request->https ? 'https://' : 'http://') . $request->SERVER['HTTP_HOST'];
        return new Tenant_HTTP_Response_RobotsTxt($host, $resourcePath);
    }
165824
public function match(Request $request)
    {
        try {
            return parent::match($request);
        } catch (NotFoundHttpException $e) {
            $route = $this->findMatchingWordpressPost();

            if ( ! is_null($route)) {
                return $route->bind($request);
            }

            throw $e;
        }
    }
1164376
public function get ($request, $match)
    {
        if (isset($match['collectionId'])) {
            $collectionId = $match['collectionId'];
        } else {
            $collectionId = $request->REQUEST['collectionId'];
        }
        $collection = Pluf_Shortcuts_GetObjectOr404('Collection_Collection', 
                $collectionId);
        $document = Pluf_Shortcuts_GetObjectOr404('Collection_Document', 
                $match['documentId']);
        if ($document->collection !== $collection->id) {
            throw new Pluf_Exception_DoesNotExist(
                    'Document with id (' . $document->id .
                             ') does not exist in collection with id (' .
                             $collection->id . ')');
        }
        return new Pluf_HTTP_Response_Json($document);
    }
1352426
public function loadResource($request, $match)
    {
        // First part of path
        $firstPart = $match['firstPart'];
        // Remain part of path
        $remainPart = '';
        if (array_key_exists('remainPart', $match)) {
            $remainPart = $match['remainPart'];
        }

        $spa = Tenant_SPA::getSpaByName($firstPart);
        if (isset($spa)) { // SPA is valid
            $path = $remainPart;
            $spaName = $firstPart;
        } else {
            // first part is not an SPA so use default SPA
            $path = isset($remainPart) && ! empty($remainPart) ? $firstPart . '/' . $remainPart : $firstPart;

            // find a resource
            $tenantResource = $this->findTenantResource('/' . $path);
            if ($tenantResource) {
                return new Pluf_HTTP_Response_File($tenantResource->getAbsloutPath(), $tenantResource->mime_type);
            }

            // [OR] check for default spa
            $name = Tenant_Service::setting('spa.default', 'not-found');
            $spa = Tenant_SPA::getSpaByName($name);
            if ($spa === null) {
                $spa = Tenant_SpaService::getNotfoundSpa();
                $spaName = 'not-found';
            } else {
                $spaName = null;
            }
        }

        if (preg_match('/.+\.[a-zA-Z0-9]+$/', $path)) {
            // Looking for file in SPA
            $resPath = $spa->getResourcePath($path);
            $isMain = false;
        } else {
            // [OR]Request is for main file (path is an internal state)
            $resPath = $spa->getMainPagePath();
            $isMain = true;
        }
        if ($isMain) {
            return new Tenant_HTTP_Response_SpaMain($resPath, Pluf_FileUtil::getMimeType($resPath), $spaName);
        } else {
            return new Pluf_HTTP_Response_File($resPath, Pluf_FileUtil::getMimeType($resPath));
        }
    }
816235
public function find ($request, $match)
    {
        $location = Geo_Shortcuts_GetLocationOr404($match[1]);
        $count = 10;
        $pag = new Pluf_Paginator(new SaaSKM_Vote());
        $pag->list_filters = array(
                'voter'
        );
        $sql = new Pluf_SQL('tenant=%s AND owner_class=%s AND owner_id=%s', 
                array(
                        $request->tenant->id,
                        'Geo_Location',
                        $location->id
                ));
        $pag->forced_where = $sql;
        $list_display = array(
                'vote_value' => __('location title'),
                'vote_comment' => __('description')
        );
        $search_fields = array(
                'voter',
                'vote_comment'
        );
        $sort_fields = array(
                'voter',
                'creation_date',
                'modif_dtime'
        );
        $pag->configure($list_display, $search_fields, $sort_fields);
        $pag->items_per_page = $count;
        $pag->sort_order = array(
                'creation_dtime',
                'DESC'
        );
        $pag->setFromRequest($request);
        return new Pluf_HTTP_Response_Json($pag->render_object());
    }