Backend\Core\Engine\Model::getExtrasForData PHP Method

getExtrasForData() public static method

Get extras for data
public static getExtrasForData ( string $module, string $key, string $value, string $action = null ) : array
$module string The module for the extra.
$key string The key of the data you want to check the value for.
$value string The value to check the key for.
$action string In case you want to search for a certain action.
return array The ids for the extras.
    public static function getExtrasForData($module, $key, $value, $action = null)
    {
        // init variables
        $module = (string) $module;
        $key = (string) $key;
        $value = (string) $value;
        $result = array();
        // init query
        $query = 'SELECT i.id, i.data
                 FROM modules_extras AS i
                 WHERE i.module = ? AND i.data != ?';
        // init parameters
        $parameters = array($module, 'NULL');
        // we have an action
        if ($action) {
            $query .= ' AND i.action = ?';
            $parameters[] = (string) $action;
        }
        // get items
        $items = (array) self::getContainer()->get('database')->getPairs($query, $parameters);
        // stop here when no items
        if (empty($items)) {
            return $result;
        }
        // loop items
        foreach ($items as $id => $data) {
            $data = unserialize($data);
            if (isset($data[$key]) && $data[$key] == $value) {
                $result[] = $id;
            }
        }
        return $result;
    }