idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
8,300 | private function replaceDummy ( $ directory ) { $ files = File :: allFiles ( $ directory ) ; foreach ( $ files as $ file ) { $ this -> replaceDummyInFile ( $ file -> getPathName ( ) ) ; } return $ this ; } | Replace dummy strings in a directory s files |
8,301 | private function replaceDummyInFile ( $ filePath ) { $ fileSource = File :: get ( $ filePath ) ; $ fileContent = str_replace ( array_keys ( $ this -> dummyReplacements ) , array_values ( $ this -> dummyReplacements ) , $ fileSource ) ; $ writeFile = File :: put ( $ filePath , $ fileContent ) ; if ( $ writeFile === fals... | Replace dummy content in a file |
8,302 | public static function getConstants ( $ objectOrClass ) : array { try { $ reflectionClass = self :: getReflectionClass ( $ objectOrClass ) ; return $ reflectionClass -> getConstants ( ) ; } catch ( \ Exception $ e ) { return [ ] ; } } | Get constants . |
8,303 | public static function getProperties ( ? object $ object , ? string $ classOverride = null , ? int $ propertyType = null ) : array { $ reflectionClass = self :: getReflectionClass ( $ object , $ classOverride ) ; $ properties = [ ] ; $ reflectionProperties = $ reflectionClass -> getProperties ( $ propertyType ) ; forea... | Get properties . |
8,304 | public static function callMethod ( string $ name , ? object $ object , array $ arguments = [ ] , ? string $ classOverride = null ) { $ method = self :: getReflectionMethod ( $ name , $ object , $ classOverride ) ; $ method -> setAccessible ( true ) ; if ( count ( $ arguments ) > 0 ) { return $ method -> invokeArgs ( $... | Call method . |
8,305 | public static function hasInterface ( $ objectOrClass , string $ interfaceClassName ) : bool { return in_array ( $ interfaceClassName , self :: getInterfaces ( $ objectOrClass ) ) ; } | Has interface . |
8,306 | public static function getExtends ( $ objectOrClass ) : array { if ( is_object ( $ objectOrClass ) ) { $ objectOrClass = get_class ( $ objectOrClass ) ; } return array_values ( class_parents ( $ objectOrClass ) ) ; } | Get extends . |
8,307 | public static function hasMethod ( string $ method , $ objectOrClass ) : bool { try { $ reflectionClass = self :: getReflectionClass ( $ objectOrClass ) ; return $ reflectionClass -> hasMethod ( $ method ) ; } catch ( Exception $ e ) { return false ; } } | Has method . |
8,308 | private static function getReflectionClass ( $ objectOrClass , $ classOverride = null ) : ReflectionClass { $ class = $ classOverride ; if ( $ class === null ) { if ( is_object ( $ objectOrClass ) ) { $ class = get_class ( $ objectOrClass ) ; } else { $ class = $ objectOrClass ; } } return new ReflectionClass ( $ class... | Get reflection class . |
8,309 | private static function getReflectionMethod ( string $ method , $ objectOrClass , $ classOverride = null ) : ReflectionMethod { $ class = $ classOverride ; if ( $ class === null ) { if ( is_object ( $ objectOrClass ) ) { $ class = get_class ( $ objectOrClass ) ; } else { $ class = $ objectOrClass ; } } return new Refle... | Get reflection method . |
8,310 | public function setRotationCount ( $ count ) { $ count = intval ( $ count ) ; if ( $ count != 0 ) { $ count = $ count % 4 ; $ this -> rotationCount = $ count ; } return $ this ; } | Set right angle rotation count . Negative is CCW |
8,311 | public function getAllPosts ( $ lang , $ postType ) { if ( ! User :: hasAccess ( $ postType , 'read' ) ) { return $ this -> noPermission ( ) ; } $ defaultOrderBy = 'postID' ; $ orderBy = ( Input :: get ( 'order' ) ) ? Input :: get ( 'order' ) : $ defaultOrderBy ; $ orderType = ( Input :: get ( 'type' ) ) ? Input :: get... | Get all post of a post type . |
8,312 | public function getDataForCreate ( $ lang , $ postTypeSlug ) { $ customFieldsGroups = CustomFieldGroup :: findGroups ( 'post-type' , 'create' , 0 , $ postTypeSlug ) ; $ postType = PostType :: where ( 'slug' , $ postTypeSlug ) -> first ( ) ; $ categories = array_values ( Category :: where ( "postTypeID" , $ postType -> ... | Get all data needed in the post create form . Fields Custom Fields Categories Languages . |
8,313 | public function getInTableColumns ( $ postType ) { $ inTableColumnsSlugs = [ ] ; $ fields = PostType :: getFields ( $ postType ) ; foreach ( Post :: $ defaultListColumns as $ key => $ label ) { if ( substr ( $ label , 0 , 2 ) == '__' ) { $ label = __ ( substr ( $ label , 2 ) ) ; } $ inTableColumnsSlugs [ $ key ] = $ la... | Get columns list that will be used only in post list table . Used to add extra columns in post list table . |
8,314 | private function selectByCategory ( $ queryObject , $ categoryID , $ postTypeSlug ) { $ categoryRelationTable = categoriesRelationTable ( $ postTypeSlug ) ; return $ queryObject -> join ( $ categoryRelationTable , $ categoryRelationTable . '.postID' , $ postTypeSlug . '.postID' ) -> where ( $ categoryRelationTable . '.... | Joins post with category and selects only ones that have the specific category . |
8,315 | private function appendListColumnsFromEvents ( string $ postType ) { Event :: listen ( 'post:table_list_rows' , function ( $ results ) use ( $ postType ) { $ rows = [ ] ; $ inTableColumns = $ this -> getInTableColumns ( $ postType ) ; foreach ( $ results as $ key => $ item ) { if ( array_key_exists ( 'title' , $ inTabl... | Create event table_list_rows to manipulate with data elsewhere . |
8,316 | public function getAllPostsOfCategory ( $ lang , $ postType , $ categoryID ) { if ( ! User :: hasAccess ( $ postType , 'read' ) ) { return $ this -> noPermission ( ) ; } $ orderBy = ( isset ( $ _GET [ 'order' ] ) ) ? $ _GET [ 'order' ] : 'postID' ; $ orderType = ( isset ( $ _GET [ 'type' ] ) ) ? $ _GET [ 'type' ] : 'DE... | Get all post of a category . |
8,317 | public function store ( Request $ request ) { $ data = $ request -> all ( ) ; if ( isset ( $ data [ 'postID' ] ) ) { if ( ! User :: hasAccess ( $ request -> postType , 'update' , $ data [ 'postID' ] , true ) ) { return $ this -> noPermission ( ) ; } } else { if ( ! User :: hasAccess ( $ request -> postType , 'create' )... | This function is used to store the post in the database . Is used to store the media relations too . |
8,318 | public function fillEmptySlugs ( $ slugList , $ postType , $ defaultSlug , $ id = 0 ) { $ slugsFinal = array ( ) ; foreach ( $ slugList as $ languageSlug => $ slug ) { $ tmpSlug = $ slug ; if ( $ slug == "" ) { $ tmpSlug = $ defaultSlug ; } $ checkedSlug = parent :: generateSlug ( $ tmpSlug , $ postType , 'postID' , $ ... | Slug shouldn t be empty . Fills slug from default language to all other languages slugs . |
8,319 | public function detailsJSON ( $ lang , $ postTypeSlug , $ id ) { if ( ! User :: hasAccess ( $ postTypeSlug , 'update' , $ id , true ) ) { return $ this -> noPermission ( ) ; } $ currentPostType = PostType :: findBySlug ( $ postTypeSlug ) ; $ post = ( new Post ( ) ) -> setTable ( $ postTypeSlug ) -> find ( $ id ) ; if (... | All required data for post update form . |
8,320 | private function getPostRelatedMedia ( $ id , $ post , $ postTypeSlug , $ translatableFields ) { $ media = array ( ) ; $ mediaRelationTable = $ postTypeSlug . '_media' ; $ mediaRelationsResults = DB :: table ( $ mediaRelationTable ) -> join ( 'media' , $ mediaRelationTable . '.mediaID' , 'media.mediaID' ) -> join ( $ p... | Get all media related to a single post . |
8,321 | private function getPostSelectedCategories ( $ id , $ postTypeSlug ) { $ categoryRelationTable = $ postTypeSlug . '_categories' ; $ selectedCategories = DB :: table ( $ categoryRelationTable ) -> leftJoin ( 'categories' , $ categoryRelationTable . '.categoryID' , 'categories.categoryID' ) -> where ( $ categoryRelationT... | Get selected categories of a single post . |
8,322 | private function getPostSelectedTags ( $ id , $ postTypeSlug ) { $ selectedTags = [ ] ; $ tagsRelationTable = tagsRelationTable ( $ postTypeSlug ) ; $ tagsRelations = DB :: table ( $ tagsRelationTable ) -> leftJoin ( 'tags' , $ tagsRelationTable . '.tagID' , 'tags.tagID' ) -> where ( $ tagsRelationTable . '.postID' , $... | Get selected tags of a single post . |
8,323 | public function getSlug ( $ lang , $ postType , $ slug ) { return parent :: generateSlug ( $ slug , $ postType , 'postID' , $ lang , 0 , true ) ; } | This function creates the slug for a category and makes sure that slugs it is not being used from a other category . |
8,324 | public function menuPanelItems ( $ lang = "" , $ postType ) { if ( ! User :: hasAccess ( 'PostType' , 'read' ) ) { return $ this -> noPermission ( ) ; } $ postsObj = ( new Post ( ) ) -> setTable ( $ postType ) ; $ postsObj = $ postsObj -> published ( ) ; if ( Input :: input ( 'keyword' ) ) { $ postsObj -> where ( 'titl... | Get posts to be displayed in menu panel . |
8,325 | private function truncate ( OutputInterface $ output ) { $ output -> writeln ( 'Removing pages ...' ) ; $ em = $ this -> getContainer ( ) -> get ( 'ekyna_cms.page.manager' ) ; $ repository = $ this -> getContainer ( ) -> get ( 'ekyna_cms.page.repository' ) ; $ count = 0 ; $ pages = $ repository -> findAll ( ) ; foreach... | Removes all the pages . |
8,326 | public function setResource ( ResourceInterface $ resource = null ) { $ this -> resource = $ resource ; $ this -> urls = null ; return $ this ; } | Sets the current resource . |
8,327 | public function getUrls ( array $ locales = [ ] ) { if ( ! is_null ( $ this -> urls ) ) { return $ this -> urls ; } $ locales = $ locales ? : $ this -> locales ; $ this -> urls = [ ] ; if ( $ this -> resource ) { $ this -> resourceHelper -> getEntityManager ( ) -> refresh ( $ this -> resource ) ; foreach ( $ locales as... | Returns the urls . |
8,328 | public function store ( $ prefix , $ key , $ default , $ timestamp , $ ttl ) { $ value = $ this -> processDefault ( $ default ) ; if ( $ value === null ) { return $ value ; } $ this -> driver -> set ( $ prefix , $ key , $ value , $ timestamp , $ ttl ) ; return $ value ; } | Generate store and return |
8,329 | private function handlePage ( PageInterface $ page ) { $ doRecompute = false ; $ dynamicPath = $ this -> hasDynamicPath ( $ page ) ; if ( $ dynamicPath != $ page -> isDynamicPath ( ) ) { $ page -> setDynamicPath ( $ dynamicPath ) ; $ doRecompute = true ; } $ advanced = $ this -> isAdvanced ( $ page ) ; if ( null !== $ ... | Handles the page . |
8,330 | private function hasDynamicPath ( PageInterface $ page ) { if ( empty ( $ route = $ page -> getRoute ( ) ) ) { return false ; } if ( null === $ route = $ this -> findRoute ( $ route ) ) { return false ; } if ( preg_match_all ( '~\{([^\}]+)\}~' , $ route -> getPath ( ) , $ matches , PREG_SET_ORDER ) ) { foreach ( $ matc... | Returns whether the page has dynamic path or not . |
8,331 | private function findRoute ( $ name ) { if ( null === $ this -> routes ) { $ i18nRouterClass = 'JMS\I18nRoutingBundle\Router\I18nRouterInterface' ; if ( interface_exists ( $ i18nRouterClass ) && $ this -> router instanceof $ i18nRouterClass ) { $ this -> routes = $ this -> router -> getOriginalRouteCollection ( ) ; } e... | Finds the route for the given name . |
8,332 | private function buildPageRedirections ( PageInterface $ page ) { if ( ! $ page -> isEnabled ( ) ) { $ redirections = [ ] ; $ locales = [ ] ; foreach ( $ page -> getTranslations ( ) as $ locale => $ translation ) { $ locales [ $ locale ] = $ locale ; $ redirections [ $ locale ] = [ 'from' => $ translation -> getPath ( ... | Builds redirections for the page . |
8,333 | private function discardPageRedirections ( PageInterface $ page ) { if ( $ page -> isEnabled ( ) ) { foreach ( $ page -> getTranslations ( ) as $ locale => $ translation ) { $ localePrefix = $ locale != 'fr' ? '/' . $ locale : '' ; $ event = new DiscardRedirectionEvent ( $ localePrefix . $ translation -> getPath ( ) ) ... | Discards redirections for the page . |
8,334 | private function isAdvanced ( PageInterface $ page ) { if ( null !== $ controller = $ page -> getController ( ) ) { if ( array_key_exists ( $ controller , $ this -> pageConfig [ 'controllers' ] ) ) { return $ this -> pageConfig [ 'controllers' ] [ $ controller ] [ 'advanced' ] ; } throw new \ RuntimeException ( "Undefi... | Returns whether the page is advanced or not . |
8,335 | public function getAll ( $ lang = "" ) { $ orderBy = ( isset ( $ _GET [ 'order' ] ) ) ? $ orderBy = $ _GET [ 'order' ] : 'customFieldGroupID' ; $ orderType = ( isset ( $ _GET [ 'type' ] ) ) ? $ orderType = $ _GET [ 'type' ] : 'DESC' ; return CustomFieldGroup :: orderBy ( $ orderBy , $ orderType ) -> paginate ( CustomFi... | Used to get the list of custom field groups . |
8,336 | public function divideParentFromChildren ( $ customFieldsArr ) { $ parents = [ ] ; $ children = [ ] ; for ( $ i = 0 ; $ i < count ( $ customFieldsArr ) ; $ i ++ ) { if ( ! $ customFieldsArr [ $ i ] [ 'parentID' ] ) { $ parents [ ] = $ customFieldsArr [ $ i ] ; } else { if ( ! isset ( $ children [ $ customFieldsArr [ $ ... | Divides Fields from sub fields in two different arrays . |
8,337 | public function delete ( $ lang , $ id ) { if ( ! User :: hasAccess ( 'CustomField' , 'delete' ) ) { return $ this -> noPermission ( ) ; } $ customFieldGroup = CustomFieldGroup :: find ( $ id ) ; if ( $ customFieldGroup ) { $ fields = CustomField :: where ( 'customFieldGroupID' , $ id ) ; if ( $ fields ) { $ fields -> ... | Delete a custom field group from database . |
8,338 | public function bulkDelete ( Request $ request ) { if ( ! User :: hasAccess ( 'CustomField' , 'delete' ) ) { return $ this -> noPermission ( ) ; } $ data = $ request -> all ( ) ; foreach ( $ data as $ id ) { $ customFieldsGroup = CustomFieldGroup :: find ( $ id ) -> delete ( ) ; if ( ! $ customFieldsGroup ) { return $ ... | Bulk Delete custom fields groups and their custom fields . |
8,339 | public function generateFieldSlugRequest ( Request $ request ) { $ id = $ request -> id ; $ title = $ request -> title ; $ keys = $ request -> keys ; return $ this -> generateFieldSlug ( '' , $ title , $ id , $ keys ) ; } | Catches the post request from frontend . |
8,340 | private function guessTemplateName ( ) { if ( $ this -> package === null ) { throw new \ RuntimeException ( sprintf ( 'Block package is unknown, thus it is impossible to guess template name for block [%s].' , $ this -> getTitle ( ) ) ) ; } $ name = ( new \ ReflectionClass ( $ this ) ) -> getShortName ( ) ; if ( ( $ pos... | Tries to guess block template name . |
8,341 | public function createContainerAction ( Request $ request ) { $ content = $ this -> findContentByRequest ( $ request ) ; $ type = $ request -> request -> get ( 'type' , null ) ; try { $ container = $ this -> getEditor ( ) -> createDefaultContainer ( $ type , [ ] , $ content ) ; } catch ( EditorExceptionInterface $ e ) ... | Create and append a new container to the content . |
8,342 | public static function getMenuLinkRoutes ( $ controller ) { $ controllerClass = Theme :: getNamespace ( ) . '\\Controllers\\' . $ controller ; $ routes = [ ] ; if ( class_exists ( $ controllerClass ) && method_exists ( $ controllerClass , 'menuLinkRoutes' ) ) { $ routes = array_merge ( $ routes , $ controllerClass :: m... | Get getMenuLinkRoutes from a controller |
8,343 | public static function successfully ( Phone $ phone , string $ messageId = null ) : Result { return new self ( $ phone , true , $ messageId ) ; } | Create successfully result |
8,344 | public static function failed ( Phone $ phone , Error $ error , string $ messageId = null ) : Result { return new self ( $ phone , false , $ messageId , $ error ) ; } | Create failed result |
8,345 | public static function objectsToJson ( $ objectArray ) { $ tmp = [ ] ; foreach ( $ objectArray as $ key => $ item ) { if ( is_object ( $ item ) || is_array ( $ item ) ) { $ item = json_encode ( $ item ) ; } $ tmp [ $ key ] = $ item ; } return $ tmp ; } | encode a list of object or arrays as json . |
8,346 | private function searchMenuLinkUsingID ( $ list , $ id ) { foreach ( $ list as $ menuLink ) { if ( $ menuLink [ 'menuLinkID' ] == $ id ) { return $ menuLink ; } } throw new \ Exception ( "Menu link doesn't exit, something is wrong" ) ; } | Search menu link using it s ID . |
8,347 | private function setParentID ( $ newMenuLinksID ) { $ tmp = [ ] ; foreach ( $ this -> existingMenuLinks as $ menuLink ) { $ isParentNewLink = strstr ( $ menuLink [ 'parent' ] , 'NEW' ) ; if ( $ isParentNewLink ) { $ menuLink [ 'parent' ] = $ newMenuLinksID [ $ menuLink [ 'parent' ] ] ; } $ tmp [ ] = $ menuLink ; } retu... | Used to replace the parent of menu links that exists in DB but have parent a new menu link . So after inserting the new menu links in database we get their ID and use them if their are parents of existing menu links . |
8,348 | protected function getAllMenuLinkRoutes ( ) { if ( ! $ this -> allMenuLinkRoutes ) { $ menuLinkRoutes = [ ] ; if ( file_exists ( Theme :: getPath ( ) . '/controllers' ) ) { $ controllers = File :: files ( Theme :: getPath ( ) . '/controllers' ) ; foreach ( $ controllers as $ file ) { $ controllerName = str_replace ( '.... | Get all controllers menuLinkRoutes . |
8,349 | public function menuLinkPanels ( ) { $ this -> getAllMenuLinkRoutes ( ) ; $ models = File :: files ( base_path ( 'app/Models' ) ) ; $ panels = [ ] ; foreach ( $ models as $ file ) { $ modelName = str_replace ( '.php' , '' , $ file -> getFileName ( ) ) ; $ modelClass = 'App\\Models\\' . $ modelName ; if ( method_exists ... | Get all panels from controllers menuLinkRoutes . Used to create link panels options for adding in the menu . |
8,350 | public function getMenuLinkRoutes ( $ controller , $ belongsTo = '' ) { $ this -> getAllMenuLinkRoutes ( ) ; $ routes = [ ] ; if ( isset ( $ this -> allMenuLinkRoutes [ $ controller ] [ $ belongsTo ] ) ) { $ routes = $ this -> allMenuLinkRoutes [ $ controller ] [ $ belongsTo ] ; } else if ( isset ( $ this -> allMenuLin... | Get menu Link Routes by post type or return default ones . |
8,351 | public function detailsJSON ( $ lang , $ id ) { if ( ! User :: hasAccess ( 'Menu' , 'read' ) ) { return $ this -> noPermission ( ) ; } $ menu = Menu :: findByID ( $ id ) ; $ this -> existingMenuLinks = MenuLink :: where ( 'menuID' , $ id ) -> orderBy ( "order" , "ASC" ) -> get ( ) -> toArray ( ) ; $ convertedMenuLinks ... | Create a menu link parent child relation array . |
8,352 | private function convertToParentChild ( $ menuLinks ) { $ tmp = [ ] ; $ count = 0 ; foreach ( $ menuLinks as $ key => $ menuLink ) { if ( $ menuLink [ 'routeName' ] ) { $ route = Route :: getRoutes ( ) -> getByName ( $ menuLink [ 'routeName' ] ) ; if ( $ route ) { $ controller = Arr :: last ( explode ( '\\' , get_class... | Converts the one dimensional array of menu links to multidimensional array where each parent link has a object with key children where his children are stored . |
8,353 | private function getChildren ( $ parentID ) { $ tmp = [ ] ; $ count = 0 ; foreach ( $ this -> existingMenuLinks as $ key => $ menuLink ) { if ( $ menuLink [ 'parent' ] == $ parentID ) { $ tmp [ $ count ] = $ menuLink ; $ count ++ ; } } return $ tmp ; } | Get all children of a menu link . |
8,354 | private function filterParents ( $ menuLinks ) { $ tmp = [ ] ; foreach ( $ menuLinks as $ key => $ menuLink ) { if ( isset ( $ menuLink [ 'parent' ] ) && ! $ menuLink [ 'parent' ] ) { $ tmp [ $ key ] = $ menuLink ; } } return $ tmp ; } | Remove children links from first dimension of array . |
8,355 | public function deleteMenu ( $ lang , $ menuID ) { if ( ! User :: hasAccess ( 'Menu' , 'delete' ) ) { return $ this -> noPermission ( ) ; } $ menu = Menu :: find ( $ menuID ) ; if ( ! $ menu ) { return $ this -> response ( "Menu doesn't exist" , 400 ) ; } if ( ! $ menu -> isPrimary ) { $ menuLinks = MenuLink :: where (... | Delete menu with his menu links . |
8,356 | public function getFlashMessage ( $ params , $ content , \ Smarty_Internal_Template $ template , & $ repeat ) { $ type = $ this -> getParam ( $ params , 'type' , false ) ; if ( null === $ content ) { $ this -> results = new FlashMessageBag ( ) ; if ( false === $ type ) { $ this -> results -> addAll ( $ this -> getSessi... | Get FlashMessage And clean session from this key |
8,357 | public static function setActiveIDs ( $ reset = false ) { if ( ! self :: $ activeIDs || $ reset ) { $ currentRoute = \ Request :: route ( ) ; $ currentMenuLinkIDs = [ ] ; $ isDefaultLanguage = ( App :: getLocale ( ) == Language :: getDefault ( 'slug' ) ? '.default' : false ) ; foreach ( MenuLink :: all ( ) as $ menuLin... | Set current MenuLink IDs . |
8,358 | private static function matchRoute ( & $ currentMenuLinkIDs , $ menuLink , $ currentRoute , $ menuLinkRoute ) { $ menuLinksParams = self :: decodeParams ( $ menuLink -> params ) ; if ( App :: getLocale ( ) != Language :: getDefault ( 'slug' ) ) { $ menuLinksParams [ 'lang' ] = App :: getLocale ( ) ; } $ paramsMatch = t... | Match route based on current menulink and route |
8,359 | private static function checkCategoryMatch ( & $ currentMenuLinkIDs , $ menuLink ) { if ( Meta :: getModelData ( ) && isset ( $ menuLink -> params -> categoryID ) && isset ( Meta :: getModelData ( ) -> categories ) && count ( Meta :: getModelData ( ) -> categories ) ) { foreach ( Meta :: getModelData ( ) -> categories ... | Check if the menulink has a category linked to currrent Meta model data |
8,360 | public static function getActive ( ) { self :: setActiveIDs ( ) ; if ( self :: getActiveIDs ( ) ) { return MenuLink :: findByID ( current ( self :: getActiveIDs ( ) ) ) ; } return ; } | Get first active menulink |
8,361 | public static function getCurrent ( $ columnName = '' ) { if ( $ columnName ) { if ( isset ( self :: $ currentMenuLink -> $ columnName ) ) { return self :: $ currentMenuLink -> $ columnName ; } return ; } return self :: $ currentMenuLink ; } | Get current MenuLink ID |
8,362 | public static function getCurrentParam ( $ paramKey ) { if ( self :: $ currentMenuLink ) { if ( isset ( self :: $ currentMenuLink -> params -> $ paramKey ) ) { return self :: $ currentMenuLink -> params -> $ paramKey ; } } return null ; } | Get a param from current MenuLink |
8,363 | public static function findBySlug ( $ slug , $ languageSlug = "" ) { $ getMenuLink = array_where ( MenuLink :: all ( ) , function ( $ value ) use ( $ slug ) { return ( $ value [ 'slug' ] == $ slug ) ; } ) ; if ( $ getMenuLink ) { return array_first ( $ getMenuLink ) ; } return false ; } | Get menulink by slug . |
8,364 | public function isActive ( $ class = '' ) { $ isActive = false ; if ( in_array ( $ this -> menuLinkID , self :: getActiveIDs ( ) ) ) { $ isActive = true ; } if ( $ isActive && $ class ) { return $ class ; } return $ isActive ; } | Checks if a given MenuLinkID is currently active in navigation |
8,365 | public static function parentID ( $ menuLinkID ) { $ parentIDs = [ ] ; while ( $ menuLinkID != null ) { $ parentObj = MenuLink :: all ( ) -> where ( 'menuLinkID' , $ menuLinkID ) -> first ( ) ; if ( $ parentObj ) { $ menuLinkID = $ parentObj -> parent ; if ( $ menuLinkID ) { $ parentIDs [ ] = $ menuLinkID ; } } if ( $ ... | Get all parents IDs of a MenuLink |
8,366 | public static function redirectToDefaultLanguage ( ) { $ getCurrentPath = Request :: path ( ) ; $ explodePath = explode ( '/' , $ getCurrentPath ) ; if ( App :: getLocale ( ) == Language :: getDefault ( "slug" ) ) { $ countPaths = count ( $ explodePath ) ; $ getLanguage = Language :: findBySlug ( $ explodePath [ 0 ] ) ... | Redirect url to default language if default language slug is given . |
8,367 | public static function getActionOfLink ( $ menuLink ) { if ( $ menuLink -> belongsTo == "post_type" ) { return route ( 'backend.post.index' , [ 'post_type' => "post_" . $ menuLink -> params -> postTypeSlug , 'view' => 'list' ] ) ; } else if ( substr ( $ menuLink -> belongsTo , 0 , 5 ) == "post_" && $ menuLink -> belong... | Generate action of a link and its params as defined in Routes . |
8,368 | public static function cmsMenus ( ) { $ result = [ ] ; foreach ( Menu :: all ( ) as $ menu ) { $ result [ $ menu -> slug ] = [ 'menuID' => $ menu -> menuID , 'title' => $ menu -> title , 'menuLinks' => self :: cmsMenuLinks ( Menu :: getMenuLinks ( $ menu -> slug ) ) , ] ; } return $ result ; } | Use to get all menus and the menu links of each of them |
8,369 | public static function cmsMenuLinks ( $ menuLinks = [ ] ) { $ links = [ ] ; $ count = 0 ; if ( $ menuLinks ) { foreach ( $ menuLinks as $ menuLink ) { if ( $ menuLink -> belongsTo == "post_type" ) { $ permission = User :: hasAccess ( $ menuLink -> slug , "read" ) ; } elseif ( $ menuLink -> belongsTo == "category" ) { $... | Get MenuLinks to be shown in Admin Panel |
8,370 | public static function decodeParams ( $ params ) { if ( ! $ params ) { return [ ] ; } $ paramsArrayList = json_decode ( json_encode ( $ params ) , true ) ; $ decodedParams = [ ] ; foreach ( $ paramsArrayList as $ paramKey => $ paramValue ) { if ( is_array ( $ paramValue ) ) { foreach ( $ paramValue as $ languageSlug =>... | Translate menulinks params to a single dimensional array and returns only current language params |
8,371 | private static function setParams ( $ menuLink ) { $ menuLinkParams = self :: decodeParams ( $ menuLink -> params ) ; $ routeParams = Route :: getRoutes ( ) -> getByName ( $ menuLink -> routeName ) -> parameterNames ( ) ; $ params = [ ] ; foreach ( $ routeParams as $ key ) { if ( isset ( $ menuLinkParams [ $ key ] ) ) ... | Find which params belongs to an action and gets their values from Menu Links Params |
8,372 | public static function children ( $ menuLinks , $ parentID = 0 , $ level = 1 ) { if ( $ level == 1 ) { $ fetchMenuList = $ menuLinks -> where ( 'parent' , null ) ; } else { $ fetchMenuList = $ menuLinks -> where ( 'parent' , $ parentID ) ; } $ fetchMenuList = $ fetchMenuList -> sortBy ( 'order' ) ; if ( $ fetchMenuList... | Get children of a menu link . |
8,373 | public function getHrefAttribute ( ) { if ( Route :: getRoutes ( ) -> getByName ( $ this -> routeName ) ) { if ( $ this -> params ) { $ params = self :: setParams ( $ this ) ; $ url = route ( $ this -> routeName , $ params ) ; } else { $ url = route ( $ this -> routeName ) ; } return $ url ; } else { throw new \ Except... | Generate the URL to a MenuLink . |
8,374 | public static function initialize ( $ request ) { Menu :: setPrimaryMenuID ( ) ; if ( isInAdmin ( ) ) { $ menuLinkID = ( is_numeric ( Input :: get ( 'menu_link_id' ) ) ? Input :: get ( 'menu_link_id' ) : false ) ; if ( $ menuLinkID ) { self :: setCurrent ( self :: findByID ( $ menuLinkID ) ) ; } } else { Post :: sethom... | Initialize MenuLink . |
8,375 | protected function authenticate ( Url $ url ) { if ( ! $ url -> getOption ( 'role' ) || ! $ url -> getOption ( 'firewall' ) ) { return $ this ; } $ session = $ this -> session ; $ firewall = $ url -> getOption ( 'firewall' ) ; $ role = $ url -> getOption ( 'role' ) ; $ user = $ this -> environmentBuilder -> getAuthenti... | Authenticates a user if is needed . |
8,376 | protected function expireAuthentication ( Url $ url ) { $ session = $ this -> session ; $ session -> remove ( '_security_' . $ url -> getOption ( 'firewall' ) ) ; $ session -> save ( ) ; $ this -> client -> getCookieJar ( ) -> expire ( $ session -> getName ( ) ) ; return $ this ; } | Expires the authentication if these has been created |
8,377 | public function openArchive ( $ location ) { $ location = str_replace ( '/' , DIRECTORY_SEPARATOR , $ location ) ; if ( ( $ response = $ this -> archive -> open ( $ location , ZipArchive :: CREATE ) ) !== true ) { throw new \ LogicException ( 'Could not open zip archive at:' . $ location . ', error: ' . $ response ) ; ... | Open a zip file . |
8,378 | public function addCsv ( CsvModelInterface $ csvModel ) { $ this -> archive -> addFromString ( $ csvModel -> getFilename ( ) , CsvGenerator :: generateCSV ( $ csvModel ) ) ; } | Add a Csv |
8,379 | public function validate ( File $ file , $ typeName , $ sourceFilePath = null ) { $ name = $ file -> getFileName ( ) ; $ fileNameHelper = new Helpers \ FileNameValidationHelper ( ) ; $ result = $ fileNameHelper -> validate ( $ name ) ; if ( ! $ result ) { $ message = $ fileNameHelper -> getErrorMessage ( ) ; throw new ... | Validates filename for files and folders |
8,380 | private function getArgsFromParam ( $ params , $ exclude = array ( ) ) { $ pairs = array ( ) ; foreach ( $ params as $ name => $ value ) { if ( in_array ( $ name , $ exclude ) ) { continue ; } $ pairs [ $ name ] = $ value ; } return $ pairs ; } | Get URL parameters array from parameters . |
8,381 | public function setPreviousUrlFunction ( $ params , & $ smarty ) { $ ignore_current = $ this -> getParam ( $ params , 'ignore_current' , false ) ; if ( $ ignore_current !== false ) { $ this -> getRequest ( ) -> attributes -> set ( '_previous_url' , 'dont-save' ) ; } else { $ this -> getRequest ( ) -> attributes -> set ... | Set the _previous_url request attribute to define the previous URL or prevent saving the current URL as the previous one . |
8,382 | public function removeHeader ( $ header ) { foreach ( $ this -> headers as $ k => $ v ) { if ( $ k === $ header ) unset ( $ this -> headers [ $ k ] ) ; } return $ this ; } | Remove a header . |
8,383 | public function getHeader ( $ header ) { foreach ( $ this -> headers as $ k => $ v ) { if ( $ v [ 0 ] === $ header ) return $ v ; } } | Get a header . |
8,384 | public function redirect ( $ url = '' ) { if ( ! preg_match ( '/^(?:\/|\\\\|\w:\\\\|\w:\/).*$/' , $ url ) && ! preg_match ( '/^[a-zA-Z0-9]*:\/\//' , $ url ) ) $ url = $ this -> request -> url -> to ( $ url ) ; $ this -> setHeader ( 'Location' , $ url ) ; if ( $ this -> code === 200 ) $ this -> setCode ( 302 ) ; return ... | Redirect the user to a given url . |
8,385 | public function createAttachedEntity ( $ entityClass , $ values = [ ] , $ key = null ) { $ this -> job -> createAttachedEntity ( $ entityClass , $ values , $ key ) ; return $ this ; } | Creates an entity and adds it . |
8,386 | public function authorizeRequest ( AbstractClient $ _client , RequestInterface & $ httpRequest ) { if ( $ this -> isRequestAuthorized ( $ httpRequest ) ) { return ; } $ httpRequest -> removeHeader ( 'Authorization' ) ; $ httpRequest -> addHeader ( 'Authorization' , 'Basic ' . $ this -> getCredentials ( ) ) ; } | Adds the authorization header to the request . If we do not have an authorization header yet we annotate the request with one . |
8,387 | public function getCode ( $ codes , $ type ) { foreach ( $ codes as $ code ) { if ( $ code -> type === $ type ) { return $ code -> type === 'external_code' ? substr ( $ code -> value , 3 ) : $ code -> value ; } } return ; } | Get the code by type If type = external_code we strip the 3 first characters |
8,388 | public function field ( string $ fieldSlug ) { foreach ( $ this -> fields as $ field ) { if ( $ field -> slug == $ fieldSlug ) { return $ field ; } } return null ; } | Get a field by using it s slug . |
8,389 | public function getMultioptionFieldValue ( string $ fieldSlug , $ key ) { if ( is_null ( $ key ) ) { return null ; } $ field = $ this -> field ( $ fieldSlug ) ; if ( ! $ field ) { throw new \ Exception ( "No field with slug " . $ fieldSlug ) ; } $ options = explode ( "," , $ field -> multioptionValues ) ; foreach ( $ o... | Get Value of a multioptions field by using it s key . |
8,390 | public static function validatePostType ( $ postTypeSlug = '' ) { if ( ! $ postTypeSlug ) { $ postTypeSlug = \ Request :: route ( 'postTypeSlug' ) ; } return ( $ postTypeSlug && ! PostType :: findBySlug ( $ postTypeSlug ) ) ; } | Validate a post type from url . |
8,391 | public static function generateSlug ( string $ slug , array $ usedSlugs ) { $ slug = camel_case ( $ slug ) ; $ count = 1 ; if ( in_array ( $ slug , $ usedSlugs ) ) { while ( true ) { $ slug = camel_case ( $ slug . "_" . $ count ) ; if ( ! in_array ( $ slug , $ usedSlugs ) ) { return $ slug ; } $ count ++ ; } } return $... | Generate slug of a field . Uses camel case to create the slug from a string . |
8,392 | public static function createTable ( $ postTypeSlug , $ fields = [ ] , $ hasCategories = false , $ hasTags = false , $ createRoutes = true , $ controller = null ) { self :: $ customFieldsArray = [ ] ; $ isTableCreated = Schema :: create ( $ postTypeSlug , function ( $ table ) use ( $ fields ) { $ table -> bigIncrements... | Create table and his columns when post type is created . |
8,393 | public static function createVirtualColumnsForSlug ( string $ postTypeSlug , $ languageSlugs = [ ] ) { $ languageSlugs = ( $ languageSlugs && ! is_array ( $ languageSlugs ) ? explode ( " " , $ languageSlugs ) : $ languageSlugs ) ; $ languageSlugs = ( $ languageSlugs ? $ languageSlugs : Language :: all ( ) -> pluck ( [ ... | Create virtual columns for slug in every language |
8,394 | private static function createMediaRelationsTable ( $ postTypeSlug ) { Schema :: create ( $ postTypeSlug . "_media" , function ( $ table ) use ( $ postTypeSlug ) { $ table -> bigIncrements ( "mediaRelationID" ) ; $ table -> bigInteger ( "postID" ) -> unsigned ( ) -> nullable ( ) ; $ table -> unsignedInteger ( "mediaID"... | Creates media relations table for the selected Post Type |
8,395 | private static function createCategoryRelationsTable ( $ postTypeSlug ) { if ( ! Schema :: hasTable ( $ postTypeSlug . "_categories" ) ) { Schema :: create ( $ postTypeSlug . "_categories" , function ( $ table ) use ( $ postTypeSlug ) { $ table -> bigIncrements ( "categoryRelationID" ) ; $ table -> bigInteger ( "postID... | Creates category relations table for the selected Post Type |
8,396 | public static function updateTable ( $ postTypeSlug , $ fields , $ hasTags = false , $ hasCategories = false ) { self :: $ customFieldsArray = [ ] ; Schema :: table ( $ postTypeSlug , function ( $ table ) use ( $ fields ) { $ post = new Post ( ) ; $ usedSlugs = [ ] ; $ usedSlugs = array_merge ( $ usedSlugs , $ post -> ... | Update post type table and add new columns . |
8,397 | private static function createDatabaseFields ( $ table , $ field , $ slug , $ isCreate = true ) { if ( $ isCreate || ( isset ( $ field [ 'canBeRemoved' ] ) && $ field [ 'canBeRemoved' ] ) ) { if ( $ field [ 'translatable' ] ) { $ table -> json ( $ slug ) -> nullable ( ) ; } else { if ( $ field [ 'type' ] [ 'inputType' ... | Create fields of post type table . |
8,398 | public static function createRouteFile ( string $ slug , $ controller = 'PostController' ) { $ stub = File :: get ( stubPath ( 'PostType' ) ) ; $ route = str_replace ( 'DummySlug' , cleanPostTypeSlug ( $ slug ) , $ stub ) ; $ route = str_replace ( 'DummyController' , $ controller , $ route ) ; $ bytes_written = File ::... | Creates route file for new post types . |
8,399 | public function add ( $ field , $ direction ) { $ this -> orderRules [ ] = array ( self :: FIELD_POS => $ field , self :: DIRECTION_POS => $ direction ) ; } | Add sorting rule |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.