public function validate_menu($package_name, $menu_data)
    {

        if (! is_string($package_name))
            throw new PackageMenuBuilderException(
                'Package root menu items should be named by string type');

        if (! is_array($menu_data))
            throw new PackageMenuBuilderException(
                'Package menu data should be defined in an array');

        // check if required keys are all sets
        foreach ($this->getRequiredKeys() as $key)
            if (! array_key_exists($key, $menu_data))
                throw new PackageMenuBuilderException(
                    'Menu should contain a ' . $key . ' entry');

        // Check if we have sub entries. If not, we have to
        // check if we have a route defined in the parent
        // menu.
        if (! array_key_exists('entries', $menu_data))
            if (! array_key_exists('route', $menu_data))
                throw new PackageMenuBuilderException(
                    'A parent or sub-menu route is required.');

        // Ensure that the entries is actually an array
        if (array_key_exists('entries', $menu_data) && ! is_array($menu_data['entries']))
            throw new PackageMenuBuilderException(
                'Root menu must define entries');

        // Loop over the sub menu entries, validating the
        // required fields
        if (isset($menu_data['entries'])) {

            foreach ($menu_data['entries'] as $entry) {

                if (! array_key_exists('name', $entry))
                    throw new PackageMenuBuilderException(
                        'A sub menu entry failed to define a name');

                if (! array_key_exists('icon', $entry))
                    throw new PackageMenuBuilderException(
                        'A sub menu entry failed to define an icon');

                if (! array_key_exists('route', $entry))
                    throw new PackageMenuBuilderException(
                        'A sub menu entry failed to define a route');

                if (isset($entry['entries'])) {

                    foreach ($entry['entries'] as $subentry) {

                        if (! array_key_exists('name', $subentry))
                            throw new PackageMenuBuilderException(
                                'A sub menu entry failed to define a name');

                        if (! array_key_exists('icon', $subentry))
                            throw new PackageMenuBuilderException(
                                'A sub menu entry failed to define an icon');

                        if (! array_key_exists('route', $subentry))
                            throw new PackageMenuBuilderException(
                                'A sub menu entry failed to define a route');

                    }

                }
            }
        }
    }
public function validate_menu($package_name, $menu_data)
    {

        if (! is_string($package_name))
            throw new PackageMenuBuilderException(
                'Package root menu items should be named by string type');

        if (! is_array($menu_data))
            throw new PackageMenuBuilderException(
                'Package menu data should be defined in an array');

        // check if required keys are all sets
        foreach ($this->getRequiredKeys() as $key)
            if (! array_key_exists($key, $menu_data))
                throw new PackageMenuBuilderException(
                    'Menu should contain a ' . $key . ' entry');

        // Check if we have sub entries. If not, we have to
        // check if we have a route defined in the parent
        // menu.
        if (! array_key_exists('entries', $menu_data))
            if (! array_key_exists('route', $menu_data))
                throw new PackageMenuBuilderException(
                    'A parent or sub-menu route is required.');

        // Ensure that the entries is actually an array
        if (array_key_exists('entries', $menu_data) && ! is_array($menu_data['entries']))
            throw new PackageMenuBuilderException(
                'Root menu must define entries');

        // Loop over the sub menu entries, validating the
        // required fields
        if (isset($menu_data['entries'])) {

            foreach ($menu_data['entries'] as $entry) {

                if (! array_key_exists('name', $entry))
                    throw new PackageMenuBuilderException(
                        'A sub menu entry failed to define a name');

                if (! array_key_exists('icon', $entry))
                    throw new PackageMenuBuilderException(
                        'A sub menu entry failed to define an icon');

                if (! array_key_exists('route', $entry))
                    throw new PackageMenuBuilderException(
                        'A sub menu entry failed to define a route');

                if (isset($entry['entries'])) {

                    foreach ($entry['entries'] as $subentry) {

                        if (! array_key_exists('name', $subentry))
                            throw new PackageMenuBuilderException(
                                'A sub menu entry failed to define a name');

                        if (! array_key_exists('icon', $subentry))
                            throw new PackageMenuBuilderException(
                                'A sub menu entry failed to define an icon');

                        if (! array_key_exists('route', $subentry))
                            throw new PackageMenuBuilderException(
                                'A sub menu entry failed to define a route');

                    }

                }
            }
        }
    }
public function validate_menu ( $ package_name , $ menu_data ) { if ( ! is_string ( $ package_name ) ) throw new PackageMenuBuilderException ( 'Package root menu items should be named by string type' ) ; if ( ! is_array ( $ menu_data ) ) throw new PackageMenuBuilderException ( 'Package menu data should be defined in an array' ) ; // check if required keys are all sets foreach ( $ this -> getRequiredKeys ( ) as $ key ) if ( ! array_key_exists ( $ key , $ menu_data ) ) throw new PackageMenuBuilderException ( 'Menu should contain a ' . $ key . ' entry' ) ; // Check if we have sub entries. If not, we have to // check if we have a route defined in the parent // menu. if ( ! array_key_exists ( 'entries' , $ menu_data ) ) if ( ! array_key_exists ( 'route' , $ menu_data ) ) throw new PackageMenuBuilderException ( 'A parent or sub-menu route is required.' ) ; // Ensure that the entries is actually an array if ( array_key_exists ( 'entries' , $ menu_data ) && ! is_array ( $ menu_data [ 'entries' ] ) ) throw new PackageMenuBuilderException ( 'Root menu must define entries' ) ; // Loop over the sub menu entries, validating the // required fields if ( isset ( $ menu_data [ 'entries' ] ) ) { foreach ( $ menu_data [ 'entries' ] as $ entry ) { if ( ! array_key_exists ( 'name' , $ entry ) ) throw new PackageMenuBuilderException ( 'A sub menu entry failed to define a name' ) ; if ( ! array_key_exists ( 'icon' , $ entry ) ) throw new PackageMenuBuilderException ( 'A sub menu entry failed to define an icon' ) ; if ( ! array_key_exists ( 'route' , $ entry ) ) throw new PackageMenuBuilderException ( 'A sub menu entry failed to define a route' ) ; if ( isset ( $ entry [ 'entries' ] ) ) { foreach ( $ entry [ 'entries' ] as $ subentry ) { if ( ! array_key_exists ( 'name' , $ subentry ) ) throw new PackageMenuBuilderException ( 'A sub menu entry failed to define a name' ) ; if ( ! array_key_exists ( 'icon' , $ subentry ) ) throw new PackageMenuBuilderException ( 'A sub menu entry failed to define an icon' ) ; if ( ! array_key_exists ( 'route' , $ subentry ) ) throw new PackageMenuBuilderException ( 'A sub menu entry failed to define a route' ) ; } } } } }
The actual menu validation logic.

@param $package_name
@param $menu_data

@throws \Seat\Web\Exceptions\PackageMenuBuilderException
The actual menu validation logic .