本文整理汇总了PHP中Zend\EventManager\SharedEventManagerInterface::detach方法的典型用法代码示例。如果您正苦于以下问题:PHP SharedEventManagerInterface::detach方法的具体用法?PHP SharedEventManagerInterface::detach怎么用?PHP SharedEventManagerInterface::detach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\EventManager\SharedEventManagerInterface
的用法示例。
在下文中一共展示了SharedEventManagerInterface::detach方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: detachShared
/**
* {@inheritDoc}
*/
public function detachShared(SharedEventManagerInterface $events)
{
foreach ($this->listeners as $listener) {
$events->detach(self::EVENT_IDENTIFIER, $listener);
}
unset($this->listeners);
}
示例2: detachShared
/**
* Detach all our listeners from the event manager
*
* @param SharedEventManagerInterface $events
* @return void
*/
public function detachShared(SharedEventManagerInterface $events)
{
if ($events->detach('Zend\\Mvc\\Application', $this->listener)) {
$this->listener = null;
}
return true;
}
示例3: detachShared
/**
* @param SharedEventManagerInterface $events
*/
public function detachShared(SharedEventManagerInterface $events)
{
foreach ($this->sharedListeners as $index => $listener) {
if ($events->detach('ZF\\Rest\\RestController', $listener)) {
unset($this->sharedListeners[$index]);
}
}
}
示例4: detachShared
/**
* @inheritdoc
*/
public function detachShared(SharedEventManagerInterface $events)
{
foreach ($this->listeners as $index => $listener) {
if ($events->detach(AclService::class, $listener)) {
unset($this->listeners[$index]);
}
}
}
示例5: detachShared
public function detachShared(\Zend\EventManager\SharedEventManagerInterface $events)
{
foreach ($this->listeners as $index => $listener) {
if ($events->detach($this->getMonitoredClass(), $listener)) {
unset($this->listeners[$index]);
}
}
}
示例6: detachShared
public function detachShared(SharedEventManagerInterface $events)
{
foreach ($this->sharedListeners as $index => $listener) {
if ($events->detach($this->eventIdentifier, $listener)) {
unset($this->sharedListeners[$index]);
}
}
}
示例7: detachShared
/**
* @inheritdoc
*/
public function detachShared(SharedEventManagerInterface $events)
{
foreach ($this->listeners as $index => $listener) {
if ($events->detach(AbstractActionController::class, $listener)) {
unset($this->listeners[$index]);
}
}
}
示例8: detachShared
public function detachShared(SharedEventManagerInterface $events)
{
foreach ($this->listeners as $index => $callback) {
if ($events->detach($id, $callback)) {
unset($this->listeners[$index]);
}
}
}
示例9: detachShared
/**
* {@inheritdoc}
*/
public function detachShared(SharedEventManagerInterface $events)
{
foreach ($this->listeners as $id => $listener) {
if ($events->detach($id, $listener)) {
unset($this->listeners[$id]);
}
}
}
示例10: detachProblemListeners
/**
* Detach problem listeners specified by getListenersToDetach() and return an array of information that will
* allow them to be reattached.
*
* @param SharedEvents $sharedEvents Shared event manager
* @return array
*/
protected function detachProblemListeners(SharedEvents $sharedEvents)
{
// Convert the problem list from two-dimensional array to more convenient id => event => class format:
$formattedProblems = array();
foreach ($this->getListenersToDetach() as $current) {
if (!isset($formattedProblems[$current['id']])) {
$formattedProblems[$current['id']] = array();
}
if (!isset($formattedProblems[$current['id']][$current['event']])) {
$formattedProblems[$current['id']][$current['event']] = array();
}
$formattedProblems[$current['id']][$current['event']][] = $current['class'];
}
// Loop through the class blacklist, detaching problem events and remembering their CallbackHandlers
// for future reference:
$results = array();
foreach ($formattedProblems as $id => $eventArray) {
$results[$id] = array();
foreach ($eventArray as $eventName => $classArray) {
$results[$id][$eventName] = array();
$events = $sharedEvents->getListeners($id, $eventName);
foreach ($events as $currentEvent) {
$currentCallback = $currentEvent->getCallback();
if (!isset($currentCallback[0])) {
continue;
}
foreach ($classArray as $class) {
if (is_a($currentCallback[0], $class)) {
$sharedEvents->detach($id, $currentEvent);
$results[$id][$eventName][] = $currentEvent;
}
}
}
}
}
return $results;
}
示例11: detachProblemListeners
/**
* Detach problem listeners specified by getListenersToDetach() and return an array of information that will
* allow them to be reattached.
*
* @param SharedEvents $sharedEvents Shared event manager
* @return array
*/
protected function detachProblemListeners(SharedEvents $sharedEvents)
{
// Convert the problem list from two-dimensional array to more convenient id => event => class format:
$formattedProblems = [];
foreach ($this->getListenersToDetach() as $current) {
if (!isset($formattedProblems[$current['id']])) {
$formattedProblems[$current['id']] = [];
}
if (!isset($formattedProblems[$current['id']][$current['event']])) {
$formattedProblems[$current['id']][$current['event']] = [];
}
$formattedProblems[$current['id']][$current['event']][] = $current['class'];
}
// Loop through the class blacklist, detaching problem events and remembering their CallbackHandlers
// for future reference:
$results = [];
foreach ($formattedProblems as $id => $eventArray) {
$results[$id] = [];
foreach ($eventArray as $eventName => $classArray) {
$results[$id][$eventName] = [];
$events = $sharedEvents->getListeners($id, $eventName);
foreach ($events as $currentEvent) {
$currentCallback = $currentEvent->getCallback();
// If we have an array, grab the object
if (is_array($currentCallback)) {
$currentCallback = array_shift($currentCallback);
}
// This routine is only valid for object callbacks
if (!is_object($currentCallback)) {
continue;
}
foreach ($classArray as $class) {
if ($currentCallback instanceof $class) {
$sharedEvents->detach($id, $currentEvent);
$results[$id][$eventName][] = $currentEvent;
}
}
}
}
}
return $results;
}
示例12: detachShared
public function detachShared(\Zend\EventManager\SharedEventManagerInterface $e)
{
foreach ($this->listeners as $index => $listener) {
if ($e->detach($listener)) {
unset($this->listeners[$index]);
}
}
}