Website Page Controller

@param string $path
@throws \Exception
@return \Symfony\Component\HttpFoundation\Response
7299
public function pageAction($path)
    {
    	$parts = explode('/', $path);
    	
    	$result = $this->get('asf_document.page.manager')->getRepository()->findBySlug($path);
    	
    	if ( count($result) == 0 ) {
    		throw new NotFoundHttpException('Ooops ! Page not found.');
    	}
    	
    	$page = $result[0];
    	
    	return $this->render('ASFWebsiteBundle:Public:page.html.twig', array(
    		'page' => $page
    	));
    }
1178976
public function createController ($stripPath = NULL)
	{
		
		// Instantiate controller
		
		$controllerObj		= new $this->controller;
		
		// Set controller variables from the url processor
		
		$controllerObj->controller	= $this->controller;
		$controllerObj->action		= $this->action;
		
		// Strip initial path from controller
		
		if ($stripPath && substr ($controllerObj->controller, 0, strlen ($stripPath)) == $stripPath)
		{
			$controllerObj->controller = substr ($controllerObj->controller, strlen ($stripPath));
		}
		
		// Return controller object
		
		return $controllerObj;
		
	}
811502
protected function getAsResponse($path, array $parameters = array(), $requestHeaders = array())
    {
        $path = $this->preparePath($path, $parameters);

        return $this->client->getHttpClient()->get($path, $requestHeaders);
    }
254212
protected function makeUrl($path)
    {
        return URL::to(str_replace('{'.$this->config['html']['href'].'}', $path, $this->customUrl));
    }
207807
public function url($path = null)
    {
        $routeAction = 'Cms\Classes\CmsController@run';

        if (self::$actionExists === null) {
            self::$actionExists = Route::getRoutes()->getByAction($routeAction) !== null;
        }

        if (substr($path, 0, 1) == '/') {
            $path = substr($path, 1);
        }

        if (self::$actionExists) {
            return Url::action($routeAction, ['slug' => $path]);
        }

        return Url::to($path);
    }
1235624
protected function getSearchResponse($path)
    {
        $extendedRequest = new ExtendedRequest();
        $extendedRequest->addQueryField('content_types', 'name');
        $extendedRequest->addQueryField('limit', 20);

        $command = new SearchContent(basename($path), $extendedRequest);

        return ResponseFactory::getResponse($this->contentClient, $command);
    }
267456
public function setPath($path)
    {
        if ($this->validatePath($path) === false) {
            require_once 'Zend/Uri/Exception.php';
            throw new Zend_Uri_Exception("Path \"$path\" is not a valid HTTP path");
        }

        $oldPath     = $this->_path;
        $this->_path = $path;

        return $oldPath;
    }
458206
public function setActive($path) {
		if (!isset($this->_nodes[$path])) {
			throw new \Exception(__METHOD__.': path "'.$path.'" does not exist.');
			return;
		}

		// set active path to retrieve the breadcrumb
		$this->_active_path = $path;

		// set all nodes to inactive
		foreach ($this->_nodes as $key => $item) {
			$this->_nodes[$key]['active'] = false;
		}

		// set actual node to active
		$actual =& $this->_nodes[$path];
		$actual['active'] = true;

		// loop to the top and set to active
		while (isset($this->_nodes[$actual['parent']])) {
			$actual =& $this->_nodes[$actual['parent']];
			$actual['active'] = true;
		}

		// return actual node
		return $this->_nodes[$path];
	}
658731
public function htmlOnlyAction($path)
    {
        try {
            $this->setPath($path);
        } catch (NotFoundException $e) {
            throw $e;
        }

        $dbfile = new WDBFile($this->getpath());
        if (!$dbfile->isFile()) {
            throw new NotFoundException(
                'Can not send raw content of a directory!',
                0, null, TemplateHelper::getRoute($dbfile->getWDBPath())
            );
        }

        $md_parser  = $this->wdb->getMarkdownParser();
        $md_content = $md_parser->transformSource($this->getPath());
        return array('layout_empty_html', 
            $md_content->getBody(),
            array('page_notes' => $md_content->getNotesToString())
        );
    }
909256
public function getChildPageByPath($path)
    {
        $page = $this;
        $pathParts = preg_split('#([/:])#', $path, -1, PREG_SPLIT_DELIM_CAPTURE);
        for($i=0; $i<count($pathParts); $i++) {
            $pathPart = $pathParts[$i];
            $i++;
            $nextSeparator = isset($pathParts[$i]) ? $pathParts[$i] : '/';
            if ($nextSeparator == '/') {
                $pages = $page->getRecursiveChildComponents(array(
                                'filename' => $pathPart,
                                'pseudoPage'=>true,
                                'limit'=>1),
                            array('pseudoPage'=>false));
            } else {
                // if path is separated by ':', id comes without '-', search for child-component
                $pages = $page->getRecursiveChildComponents(array(
                                'id' => '-' . $pathPart,
                                'pseudoPage'=>false,
                                'limit'=>1),
                            array('pseudoPage'=>false));
            }
            $page = current($pages);
            if (!$page) break;
        }
        return $page;
    }
640505
protected function _getOssClient($path)
    {
        if ($this->_oss === null) {
            $url = explode(':', $path);

            if (empty($url)) {
                throw new Exception("Unable to parse URL $path");
            }

            $this->_oss = AliyunOSS::getWrapperClient($url[0]);

            if (!$this->_oss) {
                throw new Exception("Unknown client for wrapper {$url[0]}");
            }
        }

        return $this->_oss;
    }
243102
protected function urlFromRoute($path = '')
    {
        $url = $this->baseURL;
        $url[] = $path;
        if (!empty($this->page)) $url[] = '?page=' . $this->page;
        return implode('', $url);
    }
1085820
public static function mounted($path)
    {
        $app = Router::getInstance();

        // Setup middlewares
        $app->add(new Middlewares\ResponseTypeMiddleware());
        $app->add(new Middlewares\ChannelMiddleware());
        $app->add(new Middlewares\LogMiddleware());
        $app->add(new Middlewares\AuthMiddleware());
        // $app->add(new Middlewares\SessionMiddleware());
        $app->add(new Middlewares\AppMiddleware());
        $app->add(new Middlewares\MethodOverride());

        // System
        $app->get($path . 'system/time', 'Hook\\Controllers\\SystemController:time');
        $app->get($path . 'system/ip', 'Hook\\Controllers\\SystemController:ip');

        // Collections
        $app->get($path . 'collection/:name', 'Hook\\Controllers\\CollectionController:index');
        $app->post($path . 'collection/:name', 'Hook\\Controllers\\CollectionController:store');
        $app->get($path . 'collection/:name/:id', 'Hook\\Controllers\\CollectionController:show');
        $app->put($path . 'collection/:name', 'Hook\\Controllers\\CollectionController:put');
        $app->put($path . 'collection/:name/:id', 'Hook\\Controllers\\CollectionController:put');
        $app->post($path . 'collection/:name/:id', 'Hook\\Controllers\\CollectionController:post');
        $app->delete($path . 'collection/:name(/:id)', 'Hook\\Controllers\\CollectionController:delete');

        // Auth
        $app->get($path . 'auth', 'Hook\\Controllers\\AuthController:show');
        $app->post($path . 'auth/email', 'Hook\\Controllers\\AuthController:register');
        $app->post($path . 'auth/email/login', 'Hook\\Controllers\\AuthController:login');
        $app->post($path . 'auth/email/forgotPassword', 'Hook\\Controllers\\AuthController:forgotPassword');
        $app->post($path . 'auth/email/resetPassword', 'Hook\\Controllers\\AuthController:resetPassword');
        $app->post($path . 'auth/update', 'Hook\\Controllers\\AuthController:update');

        // OAuth
        $app->get($path . 'oauth/relay_frame', 'Hook\\Controllers\\OAuthController:relay_frame');
        $app->get($path . 'oauth/:strategy(/:callback)', 'Hook\\Controllers\\OAuthController:auth');
        $app->post($path . 'oauth/callback', 'Hook\\Controllers\\OAuthController:auth');

        // Key/Value
        $app->get($path . 'key/:name', 'Hook\\Controllers\\KeyValueController:show');
        $app->post($path . 'key/:name', 'Hook\\Controllers\\KeyValueController:store');
        $app->delete($path . 'key/:name', 'Hook\\Controllers\\KeyValueController:delete');

        // Channels
        $app->get($path . 'channel/:name+', 'Hook\\Controllers\\ChannelController:index');
        $app->post($path . 'channel/:name+', 'Hook\\Controllers\\ChannelController:store');

        // Push Notifications
        $app->post($path . 'push/registration', 'Hook\\Controllers\\PushNotificationController:store');
        $app->delete($path . 'push', 'Hook\\Controllers\\PushNotificationController:delete');
        $app->get($path . 'push/notify', 'Hook\\Controllers\\PushNotificationController:notify');

        // Application management
        $app->get($path . 'apps', 'Hook\\Controllers\\ApplicationController:index');
        $app->post($path . 'apps', 'Hook\\Controllers\\ApplicationController:create');
        $app->delete($path . 'apps', 'Hook\\Controllers\\ApplicationController:delete');
        $app->delete($path . 'apps/cache', 'Hook\\Controllers\\ApplicationController:delete_cache');
        $app->get($path . 'apps/logs', 'Hook\\Controllers\\ApplicationController:logs');
        $app->get($path . 'apps/tasks', 'Hook\\Controllers\\ApplicationController:tasks');
        $app->post($path . 'apps/tasks', 'Hook\\Controllers\\ApplicationController:recreate_tasks');
        $app->get($path . 'apps/deploy', 'Hook\\Controllers\\ApplicationController:dump_deploy');
        $app->post($path . 'apps/deploy', 'Hook\\Controllers\\ApplicationController:deploy');
        $app->get($path . 'apps/configs', 'Hook\\Controllers\\ApplicationController:configs');
        $app->get($path . 'apps/keys', 'Hook\\Controllers\\ApplicationController:keys');
        $app->get($path . 'apps/modules', 'Hook\\Controllers\\ApplicationController:modules');
        $app->get($path . 'apps/schema', 'Hook\\Controllers\\ApplicationController:schema');
        $app->post($path . 'apps/schema', 'Hook\\Controllers\\ApplicationController:upload_schema');
        $app->post($path . 'apps/evaluate', 'Hook\\Controllers\\ApplicationController:evaluate');

        $app->notFound(function () use ($app) {
            echo json_encode(array('error' => 'not_found'));
        });

        //
        // Output exceptions as JSON {'error':'message'}
        //
        $app->error(function($e) use ($app) {
            echo json_encode(array('error' => $e->getMessage()));
        });

        return $app;
    }
63090
protected function loadPath($path)
    {
        $controllers = self::readdir($path);
        if(count($controllers)){
            foreach($controllers as $controller){
                $this->loadRoute($controller);
            }
        }
    }
1070792
protected function seePageIs($path)
    {
        $this->assertEquals($this->wd->getCurrentURL(), $this->baseUrl.$path);

        return $this;
    }
631871
public function download($path)
    {
        $this->setupRequest([
            'path' => $this->normalizePath($path),
        ]);

        $this->apiEndpoint = 'files/download';

        $this->content = null;

        $response = $this->doDropboxApiContentRequest();

        return StreamWrapper::getResource($response->getBody());
    }
998457
public function url($path)
    {
        $protocol = "http" . $this->isSecure();

        return $protocol . $_SERVER['HTTP_HOST'] .$this->getBaseUri() . $path;
    }