Return all filters applicable for a message.

@param Message $message
@param string  $handler

@return Filter[]
492791
public function findApplicableFiltersByMessage(Message $message, $handler = null)
    {
        if ($handler) {
            $filters = $this->findByHandler($handler);
        } else {
            $filters = $this->findAll();
        }

        $applicableFilters = [];

        $checker = new MessageChecker();
        foreach ($filters as $filter) {
            if (!$checker->checkByFilter($filter, $message)) {
                continue;
            }

            $applicableFilters[] = $filter;
        }

        return $applicableFilters;
    }
1271974
public function exportByHandle(string $handle): array
    {
        $field = Craft::$app->fields->getFieldByHandle($handle);
        return $this->export($field);
    }
662554
public function filterPrefix($prefix)
    {
        $names = [];

        foreach ($this->getMethods() as $method) {
            if ($method->isPublic() && substr_count($method->getName(), $prefix, null, strlen($prefix))) {
                $names[] = $method->getName();
            }
        }

        return $names;
    }
735123
protected function parseHandlerStr($handler)
    {
        $result = [];

        $parts = explode('::', $handler);

        $result['class']  = isset($parts[0]) ? $parts[0] : null;
        $result['method'] = isset($parts[1]) ? $parts[1] : null;

        return $result;
    }
1217362
private IMessageFilter[] getFilter(Method method, Handler subscription) {
        Filter[] filterDefinitions = collectFilters(method, subscription);
        if (filterDefinitions.length == 0) {
            return null;
        }
        IMessageFilter[] filters = new IMessageFilter[filterDefinitions.length];
        int i = 0;
        for (Filter filterDef : filterDefinitions) {
            IMessageFilter filter = filterCache.get(filterDef.value());
            if (filter == null) {
                try {
                    filter = filterDef.value().newInstance();
                    filterCache.put(filterDef.value(), filter);
                } catch (Exception e) {
                    throw new RuntimeException(e);// propagate as runtime exception
                }
            }
            filters[i] = filter;
            i++;
        }
        return filters;
    }
835221
public static function remove_messageinbound_handler($handler) {
        global $DB;

        // Delete Inbound Message datakeys.
        $DB->delete_records('messageinbound_datakeys', array('handler' => $handler->id));

        // Delete Inbound Message handlers.
        $DB->delete_records('messageinbound_handlers', array('id' => $handler->id));
    }
892215
public function success($message, $data=null){
        is_object($data) && $data = (array)$data;
        $return = ['success' => true, 'message' => $message, 'data'=>$data];
        return $return;
    }
1008364
public static function any(string $path, $handler) : array
    {
        return [
            static::get($path, $handler),
            static::post($path, $handler),
            static::put($path, $handler),
            static::patch($path, $handler),
            static::delete($path, $handler),
        ];
    }
779648
protected function getHandler($handler)
    {
        if ($handler instanceof HandlerInterface) {
            return [$handler, 'handleEvent'];
        }

        if (is_callable($handler)) {
            return $handler;
        }

        throw new InvalidArgumentException(
            sprintf('Invalid handler "%s".', is_string($handler) ? $handler : gettype($handler))
        );
    }
669134
public function filterUnReadMessagesTo($to = '')
    {
        $filteredResult = $this->filterTo($to);
        $filteredMessages = [];

        if (is_array($filteredResult) && count($filteredResult) > 0) {
            foreach ($filteredResult as $message) {
                if (isset($message['header'])) {
                    $header = $message['header'];
                    if ($header->Unseen == 'U') {
                        $filteredMessages[] = $message;
                    }
                }
            }
        }

        return $filteredMessages;
    }
394575
public function getHandlerIdsFor(array $messageFqcns)
    {
        $messageFqcns = array_flip($messageFqcns);
        $handlerIds = [];
        foreach ($this->handlers as $messageToHandlerIds) {
            $filteredMessageToHandlerIds = array_intersect_key($messageToHandlerIds, $messageFqcns);
            $handlerIds = array_merge(
                $handlerIds,
                iterator_to_array(
                    new \RecursiveIteratorIterator(new \RecursiveArrayIterator($filteredMessageToHandlerIds))
                )
            );
        }
        return array_unique($handlerIds);
    }
461155
public function getFiles(array $message)
    {
        return Collection::make($message['message']['attachments'])->where('type',
            'file')->pluck('payload')->map(function ($item) {
                return new File($item['url'], $item);
            })->toArray();
    }
852578
public function transform( $input, $handler = null )
    {
        $data = $this->getData( $input );
        return [
            'name'=>$data[ 'filepath' ],
            'width'=>$data[ 'width' ],
            'height'=>$data[ 'height' ],
            'resize'=>$data[ 'resize' ],

            'focus_point_x'=>$data[ 'focusX' ],
            'focus_point_y'=>$data[ 'focusY' ],
        ];
    }
467017
public function getExceptionByMessage($message)
    {
        $exceptions = array();
        foreach ($this->_exceptions as $e) {
            if ($message == $e->getMessage()) {
                $exceptions[] = $e;
            }
        }

        if (empty($exceptions)) {
            $exceptions = false;
        }

        return $exceptions;
    }
1264224
public function findComponentByHandler($handler)
    {
        foreach ($this->page->components as $component) {
            if ($component->methodExists($handler)) {
                return $component;
            }
        }

        foreach ($this->layout->components as $component) {
            if ($component->methodExists($handler)) {
                return $component;
            }
        }

        return null;
    }
639001
public static function get(string $messageType): array
    {
        $messages = $_SESSION[self::SESSION_KEY][$messageType] ?? [];

        unset($_SESSION[self::SESSION_KEY][$messageType]);

        return $messages;
    }
782795
public Iterator<BaseMessageFilter> getFilterList(BaseMessageHeader messageHeader)
    {
        if (messageHeader == null)
            return super.getFilterList(messageHeader);  // ALL The filters
        return this.getRegistry().getFilterList(messageHeader);
    }