main/core/Manager/EventManager.php
public function getEventsForApiFilter($restriction = null)
    {
        $resourceOption = 'resource';
        $allOption = 'all';
        $eventNames = $this->getEvents($restriction);
        sort($eventNames);
        $sortedEvents = ['all' => 'all'];
        $genericResourceEvents = ['all' => 'all'];
        $tempResourceEvents = ['all' => []];

        foreach ($eventNames as $eventName) {
            $eventNameChunks = explode('-', $eventName);
            $eventKey = "log_${eventName}_filter";

            if ($eventNameChunks[0] !== 'clacoformbundle' && !isset($sortedEvents[$eventNameChunks[0]])) {
                $sortedEvents[$eventNameChunks[0]] = ['all' => "${eventNameChunks[0]}::all"];
            }

            if ($resourceOption === $eventNameChunks[0]) {
                if (isset($eventNameChunks[2])) {
                    $tempResourceEvents[$eventNameChunks[1]][$eventKey] = $eventName;
                } else {
                    $genericResourceEvents[$eventKey] = $eventName;
                }
            } elseif ($eventNameChunks[0] === 'clacoformbundle') {
                $tempResourceEvents[$eventNameChunks[0]][$eventKey] = $eventName;
            } else {
                $sortedEvents[$eventNameChunks[0]][$eventKey] = $eventName;
            }
        }

        // adding resource types that don't define specific event classes
        $sortedEvents[$resourceOption][$allOption] = [];
        $remainingTypes = $this->om
            ->getRepository('ClarolineCoreBundle:Resource\ResourceType')
            ->findTypeNamesNotIn(array_keys($tempResourceEvents));

        foreach ($remainingTypes as $type) {
            $tempResourceEvents[$type['name']] = [];
        }

        foreach (array_keys($tempResourceEvents) as $resourceType) {
            if ($resourceType === 'resource_shortcut') {
                continue;
            }

            foreach ($genericResourceEvents as $genericEventKey => $genericEventName) {
                $eventPrefix = '';
                if ($allOption !== $resourceType) {
                    $eventPrefix = "${resourceOption}::${resourceType}::";
                }
                if ($allOption === $resourceType && $genericEventName === $allOption) {
                    $eventPrefix = "${resourceOption}::";
                }
                $sortedEvents[$resourceOption][$resourceType][$genericEventKey] = $eventPrefix.$genericEventName;
            }

            if ($allOption !== $resourceType) {
                foreach ($tempResourceEvents[$resourceType] as $resourceEventKey => $resourceEventName) {
                    $sortedEvents[$resourceOption][$resourceType][$resourceEventKey] = $resourceEventName;
                }
            }
        }

        return $this->formatEventsTableForApi($sortedEvents);
    }
public function getEventsForApiFilter($restriction = null)
    {
        $resourceOption = 'resource';
        $allOption = 'all';
        $eventNames = $this->getEvents($restriction);
        sort($eventNames);
        $sortedEvents = ['all' => 'all'];
        $genericResourceEvents = ['all' => 'all'];
        $tempResourceEvents = ['all' => []];

        foreach ($eventNames as $eventName) {
            $eventNameChunks = explode('-', $eventName);
            $eventKey = "log_${eventName}_filter";

            if ($eventNameChunks[0] !== 'clacoformbundle' && !isset($sortedEvents[$eventNameChunks[0]])) {
                $sortedEvents[$eventNameChunks[0]] = ['all' => "${eventNameChunks[0]}::all"];
            }

            if ($resourceOption === $eventNameChunks[0]) {
                if (isset($eventNameChunks[2])) {
                    $tempResourceEvents[$eventNameChunks[1]][$eventKey] = $eventName;
                } else {
                    $genericResourceEvents[$eventKey] = $eventName;
                }
            } elseif ($eventNameChunks[0] === 'clacoformbundle') {
                $tempResourceEvents[$eventNameChunks[0]][$eventKey] = $eventName;
            } else {
                $sortedEvents[$eventNameChunks[0]][$eventKey] = $eventName;
            }
        }

        // adding resource types that don't define specific event classes
        $sortedEvents[$resourceOption][$allOption] = [];
        $remainingTypes = $this->om
            ->getRepository('ClarolineCoreBundle:Resource\ResourceType')
            ->findTypeNamesNotIn(array_keys($tempResourceEvents));

        foreach ($remainingTypes as $type) {
            $tempResourceEvents[$type['name']] = [];
        }

        foreach (array_keys($tempResourceEvents) as $resourceType) {
            if ($resourceType === 'resource_shortcut') {
                continue;
            }

            foreach ($genericResourceEvents as $genericEventKey => $genericEventName) {
                $eventPrefix = '';
                if ($allOption !== $resourceType) {
                    $eventPrefix = "${resourceOption}::${resourceType}::";
                }
                if ($allOption === $resourceType && $genericEventName === $allOption) {
                    $eventPrefix = "${resourceOption}::";
                }
                $sortedEvents[$resourceOption][$resourceType][$genericEventKey] = $eventPrefix.$genericEventName;
            }

            if ($allOption !== $resourceType) {
                foreach ($tempResourceEvents[$resourceType] as $resourceEventKey => $resourceEventName) {
                    $sortedEvents[$resourceOption][$resourceType][$resourceEventKey] = $resourceEventName;
                }
            }
        }

        return $this->formatEventsTableForApi($sortedEvents);
    }
public function getEventsForApiFilter ( $ restriction = null ) { $ resourceOption = 'resource' ; $ allOption = 'all' ; $ eventNames = $ this -> getEvents ( $ restriction ) ; sort ( $ eventNames ) ; $ sortedEvents = [ 'all' => 'all' ] ; $ genericResourceEvents = [ 'all' => 'all' ] ; $ tempResourceEvents = [ 'all' => [ ] ] ; foreach ( $ eventNames as $ eventName ) { $ eventNameChunks = explode ( '-' , $ eventName ) ; $ eventKey = "log_${eventName}_filter" ; if ( $ eventNameChunks [ 0 ] !== 'clacoformbundle' && ! isset ( $ sortedEvents [ $ eventNameChunks [ 0 ] ] ) ) { $ sortedEvents [ $ eventNameChunks [ 0 ] ] = [ 'all' => "${eventNameChunks[0]}::all" ] ; } if ( $ resourceOption === $ eventNameChunks [ 0 ] ) { if ( isset ( $ eventNameChunks [ 2 ] ) ) { $ tempResourceEvents [ $ eventNameChunks [ 1 ] ] [ $ eventKey ] = $ eventName ; } else { $ genericResourceEvents [ $ eventKey ] = $ eventName ; } } elseif ( $ eventNameChunks [ 0 ] === 'clacoformbundle' ) { $ tempResourceEvents [ $ eventNameChunks [ 0 ] ] [ $ eventKey ] = $ eventName ; } else { $ sortedEvents [ $ eventNameChunks [ 0 ] ] [ $ eventKey ] = $ eventName ; } } // adding resource types that don't define specific event classes $ sortedEvents [ $ resourceOption ] [ $ allOption ] = [ ] ; $ remainingTypes = $ this -> om -> getRepository ( 'ClarolineCoreBundle:Resource\ResourceType' ) -> findTypeNamesNotIn ( array_keys ( $ tempResourceEvents ) ) ; foreach ( $ remainingTypes as $ type ) { $ tempResourceEvents [ $ type [ 'name' ] ] = [ ] ; } foreach ( array_keys ( $ tempResourceEvents ) as $ resourceType ) { if ( $ resourceType === 'resource_shortcut' ) { continue ; } foreach ( $ genericResourceEvents as $ genericEventKey => $ genericEventName ) { $ eventPrefix = '' ; if ( $ allOption !== $ resourceType ) { $ eventPrefix = "${resourceOption}::${resourceType}::" ; } if ( $ allOption === $ resourceType && $ genericEventName === $ allOption ) { $ eventPrefix = "${resourceOption}::" ; } $ sortedEvents [ $ resourceOption ] [ $ resourceType ] [ $ genericEventKey ] = $ eventPrefix . $ genericEventName ; } if ( $ allOption !== $ resourceType ) { foreach ( $ tempResourceEvents [ $ resourceType ] as $ resourceEventKey => $ resourceEventName ) { $ sortedEvents [ $ resourceOption ] [ $ resourceType ] [ $ resourceEventKey ] = $ resourceEventName ; } } } return $ this -> formatEventsTableForApi ( $ sortedEvents ) ; }
Gets formated events for API filter.

@param null|string $restriction

@return array
Gets formated events for API filter .