src/Phlexible/Bundle/ElementtypeBundle/Controller/UsageController.php
public function listAction(Request $request)
    {
        $id = $request->get('id');

        $elementtypeService = $this->get('phlexible_elementtype.elementtype_service');
        $usageManager = $this->get('phlexible_elementtype.usage_manager');

        $elementtype = $elementtypeService->findElementtype($id);

        $usages = [];
        foreach ($usageManager->getUsage($elementtype) as $usage) {
            $usages[] = [
                'type' => $usage->getType(),
                'as' => $usage->getAs(),
                'id' => $usage->getId(),
                'title' => $usage->getTitle(),
                'latest_version' => $usage->getLatestVersion(),
            ];
        }

        return new JsonResponse(['list' => $usages, 'total' => count($usages)]);
    }
public function listAction(Request $request)
    {
        $id = $request->get('id');

        $elementtypeService = $this->get('phlexible_elementtype.elementtype_service');
        $usageManager = $this->get('phlexible_elementtype.usage_manager');

        $elementtype = $elementtypeService->findElementtype($id);

        $usages = [];
        foreach ($usageManager->getUsage($elementtype) as $usage) {
            $usages[] = [
                'type' => $usage->getType(),
                'as' => $usage->getAs(),
                'id' => $usage->getId(),
                'title' => $usage->getTitle(),
                'latest_version' => $usage->getLatestVersion(),
            ];
        }

        return new JsonResponse(['list' => $usages, 'total' => count($usages)]);
    }
public function listAction ( Request $ request ) { $ id = $ request -> get ( 'id' ) ; $ elementtypeService = $ this -> get ( 'phlexible_elementtype.elementtype_service' ) ; $ usageManager = $ this -> get ( 'phlexible_elementtype.usage_manager' ) ; $ elementtype = $ elementtypeService -> findElementtype ( $ id ) ; $ usages = [ ] ; foreach ( $ usageManager -> getUsage ( $ elementtype ) as $ usage ) { $ usages [ ] = [ 'type' => $ usage -> getType ( ) , 'as' => $ usage -> getAs ( ) , 'id' => $ usage -> getId ( ) , 'title' => $ usage -> getTitle ( ) , 'latest_version' => $ usage -> getLatestVersion ( ) , ] ; } return new JsonResponse ( [ 'list' => $ usages , 'total' => count ( $ usages ) ] ) ; }
Show Usage of an Element Type.

@param Request $request

@return JsonResponse
@Route("/elementtypes/usage", name="elementtypes_usage")
Show Usage of an Element Type .