Bundle/BusinessPageBundle/Helper/BusinessPageHelper.php
public function getIdentifierPositionInUrl(BusinessTemplate $businessTemplate)
    {
        $position = null;

        $url = $businessTemplate->getUrl();

        // split on the / character
        $keywords = preg_split("/\//", $url);
        // preg_match_all('/\{\%\s*([^\%\}]*)\s*\%\}|\{\{\s*([^\}\}]*)\s*\}\}/i', $url, $matches);

        //the business property link to the page
        $businessEntityId = $businessTemplate->getBusinessEntityId();

        $businessEntity = $this->businessEntityHelper->findById($businessEntityId);

        //the business properties usable in a url
        $businessProperties = $businessEntity->getBusinessPropertiesByType('businessParameter');

        //we parse the words of the url
        foreach ($keywords as $index => $keyword) {
            foreach ($businessProperties as $businessProperty) {
                $entityProperty = $businessProperty->getEntityProperty();
                $searchWord = '{{item.'.$entityProperty.'}}';

                if ($searchWord === $keyword) {
                    //the array start at index 0 but we want the position to start at 1
                    $position = [
                        'position'         => $index + 1,
                        'businessProperty' => $businessProperty,
                    ];
                }
            }
        }

        return $position;
    }
public function getIdentifierPositionInUrl(BusinessTemplate $businessTemplate)
    {
        $position = null;

        $url = $businessTemplate->getUrl();

        // split on the / character
        $keywords = preg_split("/\//", $url);
        // preg_match_all('/\{\%\s*([^\%\}]*)\s*\%\}|\{\{\s*([^\}\}]*)\s*\}\}/i', $url, $matches);

        //the business property link to the page
        $businessEntityId = $businessTemplate->getBusinessEntityId();

        $businessEntity = $this->businessEntityHelper->findById($businessEntityId);

        //the business properties usable in a url
        $businessProperties = $businessEntity->getBusinessPropertiesByType('businessParameter');

        //we parse the words of the url
        foreach ($keywords as $index => $keyword) {
            foreach ($businessProperties as $businessProperty) {
                $entityProperty = $businessProperty->getEntityProperty();
                $searchWord = '{{item.'.$entityProperty.'}}';

                if ($searchWord === $keyword) {
                    //the array start at index 0 but we want the position to start at 1
                    $position = [
                        'position'         => $index + 1,
                        'businessProperty' => $businessProperty,
                    ];
                }
            }
        }

        return $position;
    }
public function getIdentifierPositionInUrl ( BusinessTemplate $ businessTemplate ) { $ position = null ; $ url = $ businessTemplate -> getUrl ( ) ; // split on the / character $ keywords = preg_split ( "/\//" , $ url ) ; // preg_match_all('/\{\%\s*([^\%\}]*)\s*\%\}|\{\{\s*([^\}\}]*)\s*\}\}/i', $url, $matches); //the business property link to the page $ businessEntityId = $ businessTemplate -> getBusinessEntityId ( ) ; $ businessEntity = $ this -> businessEntityHelper -> findById ( $ businessEntityId ) ; //the business properties usable in a url $ businessProperties = $ businessEntity -> getBusinessPropertiesByType ( 'businessParameter' ) ; //we parse the words of the url foreach ( $ keywords as $ index => $ keyword ) { foreach ( $ businessProperties as $ businessProperty ) { $ entityProperty = $ businessProperty -> getEntityProperty ( ) ; $ searchWord = '{{item.' . $ entityProperty . '}}' ; if ( $ searchWord === $ keyword ) { //the array start at index 0 but we want the position to start at 1 $ position = [ 'position' => $ index + 1 , 'businessProperty' => $ businessProperty , ] ; } } } return $ position ; }
Get the position of the identifier in the url of a business entity page pattern.

@param BusinessTemplate $businessTemplate

@return int The position
Get the position of the identifier in the url of a business entity page pattern .