本文整理匯總了PHP中Cx\Core\Routing\Url::fromRequest方法的典型用法代碼示例。如果您正苦於以下問題:PHP Url::fromRequest方法的具體用法?PHP Url::fromRequest怎麽用?PHP Url::fromRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cx\Core\Routing\Url
的用法示例。
在下文中一共展示了Url::fromRequest方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testFileUrls
public function testFileUrls()
{
$testResult = 'file://' . getcwd();
$url = Url::fromRequest();
$this->assertEquals($testResult, $url->toString());
$this->assertEquals(getcwd(), (string) $url);
$url = Url::fromMagic($testResult);
$this->assertEquals($testResult, $url->toString());
$this->assertEquals(getcwd(), (string) $url);
}
示例2: parsePage
/**
* Parses a rudimentary system log backend page
* @param \Cx\Core\Html\Sigma $template Backend template for this page
* @param array $cmd Supplied CMD
*/
public function parsePage(\Cx\Core\Html\Sigma $template, array $cmd)
{
$em = $this->cx->getDb()->getEntityManager();
$logRepo = $em->getRepository('Cx\\Core_Modules\\SysLog\\Model\\Entity\\Log');
// @todo: parse message if no entries (template block exists already)
$parseObject = $this->getNamespace() . '\\Model\\Entity\\Log';
// set default sorting
if (!isset($_GET['order'])) {
$_GET['order'] = 'timestamp/DESC';
}
// configure view
$viewGenerator = new \Cx\Core\Html\Controller\ViewGenerator($parseObject, array('functions' => array('delete' => 'true', 'paging' => true, 'sorting' => true, 'edit' => true), 'fields' => array('id' => array('showOverview' => false), 'timestamp' => array('readonly' => true), 'severity' => array('readonly' => true, 'table' => array('parse' => function ($data, $rows) {
return '<span class="' . contrexx_raw2xhtml(strtolower($data)) . '_background">' . contrexx_raw2xhtml($data) . '</span>';
})), 'message' => array('readonly' => true, 'table' => array('parse' => function ($data, $rows) {
$url = clone \Cx\Core\Routing\Url::fromRequest();
$url->setMode('backend');
$url->setParam('editid', $rows['id']);
return '<a href="' . $url . '">' . contrexx_raw2xhtml($data) . '</a>';
})), 'data' => array('readonly' => true, 'showOverview' => false, 'type' => 'text'), 'logger' => array('readonly' => true))));
$template->setVariable('ENTITY_VIEW', $viewGenerator);
}
示例3: getViewGeneratorOptions
/**
* This function returns the ViewGeneration options for a given entityClass
*
* @access protected
* @global $_ARRAYLANG
* @param $entityClassName contains the FQCN from entity
* @return array with options
*/
protected function getViewGeneratorOptions($entityClassName)
{
global $_ARRAYLANG;
$classNameParts = explode('\\', $entityClassName);
$classIdentifier = end($classNameParts);
$langVarName = 'TXT_' . strtoupper($this->getType() . '_' . $this->getName() . '_ACT_' . $classIdentifier);
$header = '';
if (isset($_ARRAYLANG[$langVarName])) {
$header = $_ARRAYLANG[$langVarName];
}
switch ($entityClassName) {
case 'Cx\\Core_Modules\\SysLog\\Model\\Entity\\Log':
return array('functions' => array('delete' => 'true', 'paging' => true, 'sorting' => true, 'edit' => true), 'fields' => array('id' => array('showOverview' => false), 'timestamp' => array('readonly' => true), 'severity' => array('readonly' => true, 'table' => array('parse' => function ($data, $rows) {
return '<span class="' . contrexx_raw2xhtml(strtolower($data)) . '_background">' . contrexx_raw2xhtml($data) . '</span>';
})), 'message' => array('readonly' => true, 'table' => array('parse' => function ($data, $rows) {
$url = clone \Cx\Core\Routing\Url::fromRequest();
$url->setMode('backend');
$url->setParam('editid', $rows['id']);
return '<a href="' . $url . '">' . contrexx_raw2xhtml($data) . '</a>';
})), 'data' => array('readonly' => true, 'showOverview' => false, 'type' => 'text'), 'logger' => array('readonly' => true)));
break;
default:
return array('header' => $header, 'functions' => array('add' => true, 'edit' => true, 'delete' => true, 'sorting' => true, 'paging' => true, 'filtering' => false));
}
}
示例4: postInit
/**
* Initializes request
*/
protected function postInit()
{
global $_CONFIG;
// if path configuration was wrong in loadConfig(), Url is not yet initialized
if (!$this->request) {
// this makes \Env::get('Resolver')->getUrl() return a sensful result
$request = !empty($_GET['__cap']) ? $_GET['__cap'] : '';
$offset = $this->websiteOffsetPath;
switch ($this->mode) {
case self::MODE_FRONTEND:
case self::MODE_BACKEND:
$this->request = new \Cx\Core\Routing\Model\Entity\Request($_SERVER['REQUEST_METHOD'], \Cx\Core\Routing\Url::fromCapturedRequest($request, $offset, $_GET));
break;
case self::MODE_COMMAND:
case self::MODE_MINIMAL:
try {
$this->request = new \Cx\Core\Routing\Model\Entity\Request($_SERVER['REQUEST_METHOD'], \Cx\Core\Routing\Url::fromRequest());
} catch (\Cx\Core\Routing\UrlException $e) {
}
break;
}
}
//call post-init hooks
$this->ch->callPostInitHooks();
}