本文整理汇总了PHP中Enlight_Event_EventArgs::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Enlight_Event_EventArgs::getName方法的具体用法?PHP Enlight_Event_EventArgs::getName怎么用?PHP Enlight_Event_EventArgs::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enlight_Event_EventArgs
的用法示例。
在下文中一共展示了Enlight_Event_EventArgs::getName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onGetCustomSortControllerPath
/**
* This function is responsible to resolve the backend / frontend controller path.
*
* @param \Enlight_Event_EventArgs $args
* @return string
*/
public function onGetCustomSortControllerPath(\Enlight_Event_EventArgs $args)
{
$this->templateManager->addTemplateDir($this->bootstrapPath . 'Views/');
switch ($args->getName()) {
case 'Enlight_Controller_Dispatcher_ControllerPath_Backend_CustomSort':
return $this->bootstrapPath . 'Controllers/Backend/CustomSort.php';
case 'Enlight_Controller_Dispatcher_ControllerPath_Widgets_CustomSort':
return $this->bootstrapPath . 'Controllers/Widgets/CustomSort.php';
}
}
示例2: load
/**
* Generic callback function for all registered subscribers in this class. Will dispatch the event to
* the anonymous function of the corresponding service
*
* @param \Enlight_Event_EventArgs $args
* @return mixed
*/
public function load(\Enlight_Event_EventArgs $args)
{
// get registered service from event name
$name = str_replace('Enlight_Bootstrap_InitResource_', '', $args->getName());
// call anonymous function in order to register service
$method = self::$definitions[$name];
if (!$method) {
throw new \RuntimeException("Service named {$name} not found");
}
return $method(self::$container, $args);
}
示例3: onBenchmarkEvent
/**
* @param \Enlight_Event_EventArgs $args
* @return mixed
*/
public function onBenchmarkEvent(\Enlight_Event_EventArgs $args)
{
$event = $args->getName();
if (!isset($this->results[$event])) {
$this->results[$event] = array(0 => true, 1 => 0, 2 => 0, 3 => microtime(true));
}
if (empty($this->results[$event][0])) {
$this->results[$event][0] = true;
$this->results[$event][1] -= memory_get_peak_usage(true);
$this->results[$event][2] -= microtime(true);
} else {
$this->results[$event][0] = false;
$this->results[$event][1] += memory_get_peak_usage(true);
$this->results[$event][2] += microtime(true);
}
return $args->getReturn();
}
示例4: onBenchmarkEvent
/**
* Logs all controller events into the internal log object.
* Each logged events contains the event name, the execution time and the allocated peak of memory.
*
* @param Enlight_Event_EventArgs $args
* @return void
*/
public function onBenchmarkEvent(Enlight_Event_EventArgs $args)
{
if (empty($this->results)) {
$this->results[] = array('name', 'memory', 'time');
$this->startTime = microtime(true);
$this->startMemory = memory_get_peak_usage(true);
}
$this->results[] = array(
0 => str_replace('Enlight_Controller_', '', $args->getName()),
1 => $this->formatMemory(memory_get_peak_usage(true) - $this->startMemory),
2 => $this->formatTime(microtime(true) - $this->startTime)
);
}
示例5: onEvent
/**
* Internal listener function of each fired event in shopware.
*
* @param Enlight_Event_EventArgs $args
* @return mixed
*/
public function onEvent(Enlight_Event_EventArgs $args)
{
if ($this->preventEventLog) {
return $args->getReturn();
}
$event = $args->getName();
$this->events[$event]['returns'][] = $args->getReturn();
$this->events[$event]['time'][] = microtime(true);
return $args->getReturn();
}
示例6: getDefaultControllerPath
/**
* Standard event listener function for plugin controllers.
* If the default event listener is used for the registration of a plugin controller, the following requirements must be fulfilled:
* 1. The plugin directory must contain a 'Controller' subdirectory.
* 2. The "Controllers" directory must contain a subdirectory which corresponds to the module (Frontend, Backend, Widgets or API)
* 3. The controller must be filed in the module directory.
* 4. The controller file must have the same name as the controller class.
*
* If all the requirements are fulfilled, the controller is registered automatically.
* Additionally, the following plugin namespaces/directories are registered, if available:
* 1. The 'Views' plugin directory is added as a template directory.
* 2. The 'Snippets' plugin directory is added as a config directory.
* 3. The 'Components' plugin directory is added as a component namespace.
*
* @param Enlight_Event_EventArgs $arguments
* @throws Exception
* @return string
*/
public function getDefaultControllerPath(Enlight_Event_EventArgs $arguments)
{
$eventName = $arguments->getName();
$eventName = str_replace('Enlight_Controller_Dispatcher_ControllerPath_', '', $eventName);
$parts = explode('_', $eventName);
$module = $parts[0];
$controller = $parts[1];
$path = $this->Path() . 'Controllers/' . ucfirst($module) . '/' . ucfirst($controller) . '.php';
if (!file_exists($path)) {
throw new Enlight_Exception('Controller "' . $controller . '" can\'t load failure');
}
//register plugin model directory
if (file_exists($this->Path() . 'Models')) {
$this->registerCustomModels();
}
//register plugin views directory
if (file_exists($this->Path() . 'Views')) {
$this->Application()->Template()->addTemplateDir($this->Path() . 'Views/');
}
//register plugin snippet directory
if (file_exists($this->Path() . 'Snippets')) {
$this->Application()->Snippets()->addConfigDir($this->Path() . 'Snippets/');
}
//register plugin component directory
if (file_exists($this->Path() . 'Components')) {
$this->Application()->Loader()->registerNamespace('Shopware_Components', $this->Path() . 'Components/');
}
return $path;
}