idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
18,000 | private function myCombine ( PathTraitInterface $ other , ? bool & $ isAbsolute = null , ? int & $ aboveBaseLevel = null , ? array & $ directoryParts = null , ? string & $ filename = null , ? string & $ error = null ) : bool { if ( $ other -> isAbsolute ( ) ) { $ isAbsolute = $ other -> isAbsolute ( ) ; $ aboveBaseLevel = 0 ; $ directoryParts = $ other -> getDirectoryParts ( ) ; $ filename = $ other -> getFilename ( ) ; return true ; } $ isAbsolute = $ this -> myIsAbsolute ; $ aboveBaseLevel = $ this -> myAboveBaseLevel ; $ directoryParts = $ this -> myDirectoryParts ; $ filename = $ other -> getFilename ( ) ; foreach ( $ other -> getDirectoryParts ( ) as $ otherDirectoryPart ) { if ( ! $ this -> myCombineDirectoryPart ( $ otherDirectoryPart , $ aboveBaseLevel , $ directoryParts , $ error ) ) { return false ; } } return true ; } | Tries to combine this path with another path . |
18,001 | private function myCombineDirectoryPart ( string $ part , ? int & $ aboveBaseLevel = null , ? array & $ directoryParts = null , ? string & $ error = null ) : bool { if ( $ part === '..' ) { if ( count ( $ directoryParts ) === 0 ) { if ( $ this -> myIsAbsolute ) { $ error = 'Absolute path is above root level.' ; return false ; } $ aboveBaseLevel ++ ; return true ; } array_pop ( $ directoryParts ) ; return true ; } $ directoryParts [ ] = $ part ; return true ; } | Tries to combine a directory part with another path . |
18,002 | private function myParentDirectory ( ? int & $ aboveBaseLevel = null , ? array & $ directoryParts = null ) : bool { if ( count ( $ this -> myDirectoryParts ) > 0 ) { $ aboveBaseLevel = $ this -> myAboveBaseLevel ; $ directoryParts = array_slice ( $ this -> myDirectoryParts , 0 , - 1 ) ; return true ; } if ( $ this -> myIsAbsolute ) { return false ; } $ aboveBaseLevel = $ this -> myAboveBaseLevel + 1 ; $ directoryParts = $ this -> myDirectoryParts ; return true ; } | Tries to calculate the parent directory for this path and return the result . |
18,003 | private static function myParse ( string $ directorySeparator , string $ path , callable $ partValidator , ? callable $ stringDecoder = null , ? bool & $ isAbsolute = null , ? int & $ aboveBaseLevel = null , ? array & $ directoryParts = null , ? string & $ filename = null , ? string & $ error = null ) : bool { $ parts = explode ( $ directorySeparator , $ path ) ; $ partsCount = count ( $ parts ) ; $ directoryParts = [ ] ; $ filename = null ; $ isAbsolute = false ; $ aboveBaseLevel = 0 ; $ index = 0 ; if ( $ partsCount > 1 && $ parts [ 0 ] === '' ) { $ isAbsolute = true ; $ index ++ ; } for ( ; $ index < $ partsCount ; $ index ++ ) { if ( ! self :: myParsePart ( $ parts [ $ index ] , $ index === $ partsCount - 1 , $ partValidator , $ stringDecoder , $ isAbsolute , $ aboveBaseLevel , $ directoryParts , $ filename , $ error ) ) { return false ; } } return true ; } | Tries to parse a path and returns the result or error text . |
18,004 | private static function myParsePart ( string $ part , bool $ isLastPart , callable $ partValidator , ? callable $ stringDecoder , ? bool $ isAbsolute , ? int & $ aboveBaseLevel , ? array & $ directoryParts = null , ? string & $ filename = null , ? string & $ error = null ) : bool { if ( $ part === '' || $ part === '.' ) { return true ; } if ( $ part === '..' ) { return self :: myHandleParentDirectoryPart ( $ isAbsolute , $ aboveBaseLevel , $ directoryParts , $ error ) ; } if ( ! $ isLastPart ) { return self :: myHandleDirectoryPart ( $ part , $ partValidator , $ stringDecoder , $ directoryParts , $ error ) ; } return self :: myHandleFilenamePart ( $ part , $ partValidator , $ stringDecoder , $ filename , $ error ) ; } | Tries to parse a part of a path and returns the result or error text . |
18,005 | private static function myHandleParentDirectoryPart ( bool $ isAbsolute , int & $ aboveBaseLevel , array & $ directoryParts , ? string & $ error = null ) : bool { if ( count ( $ directoryParts ) > 0 ) { array_pop ( $ directoryParts ) ; return true ; } if ( $ isAbsolute ) { $ error = 'Absolute path is above root level.' ; return false ; } $ aboveBaseLevel ++ ; return true ; } | Handles a parent directory part . |
18,006 | private static function myHandleFilenamePart ( string $ part , callable $ partValidator , ? callable $ stringDecoder = null , ? string & $ filename = null , ? string & $ error = null ) : bool { if ( ! $ partValidator ( $ part , false , $ error ) ) { return false ; } if ( $ stringDecoder !== null ) { $ part = $ stringDecoder ( $ part ) ; } $ filename = $ part ; return true ; } | Handles the file name part . |
18,007 | private static function myHandleDirectoryPart ( string $ part , callable $ partValidator , ? callable $ stringDecoder = null , ? array & $ directoryParts , ? string & $ error = null ) : bool { if ( ! $ partValidator ( $ part , true , $ error ) ) { return false ; } if ( $ stringDecoder !== null ) { $ part = $ stringDecoder ( $ part ) ; } $ directoryParts [ ] = $ part ; return true ; } | Handles the directory part . |
18,008 | public function create ( $ inputs ) { $ record = $ this -> model -> create ( $ inputs ) ; $ record -> save ( ) ; return $ record ; } | create a new record |
18,009 | public function all ( $ limit = null ) { if ( $ limit ) { return $ this -> model -> limit ( $ limit ) -> get ( ) ; } return $ this -> model -> all ( ) ; } | get all records in database |
18,010 | public function allWith ( $ with , $ limit = null ) { if ( $ limit ) { return $ this -> model -> with ( $ with ) -> limit ( $ limit ) -> get ( ) ; } return $ this -> model -> with ( $ with ) -> get ( ) ; } | get all records in database with withs |
18,011 | public function getForUser ( $ user_id = null ) { if ( $ user_id ) { return $ this -> model -> whereUserId ( $ user_id ) -> get ( ) -> first ( ) -> toArray ( ) ; } if ( auth ( ) -> user ( ) ) { return $ this -> model -> whereUserId ( auth ( ) -> user ( ) -> id ) -> first ( ) -> toArray ( ) ; } return null ; } | get the columns for a users |
18,012 | public function where ( $ key , $ value = null ) { if ( $ value ) return $ this -> model -> where ( $ key , $ value ) ; if ( is_array ( $ key ) ) return $ this -> model -> where ( $ key ) ; return null ; } | try to simulate the where of Eloquent |
18,013 | public function getPaginatedAndOrdered ( ) { $ direction = request ( ) -> get ( 'direction' ) ; $ orderBy = request ( ) -> get ( 'orderby' ) ; $ p = config ( 'admin.paginate' ) ; if ( $ orderBy ) return $ this -> orderBy ( $ orderBy , $ direction ) -> paginate ( $ p ) ; return $ this -> paginate ( ) ; } | get a record paginated and ordered |
18,014 | public function update ( $ id , $ key , $ value = null ) { $ model = $ this -> model -> find ( $ id ) ; if ( is_array ( $ key ) ) $ model -> update ( $ key ) ; else $ model -> { $ key } = $ value ; $ model -> save ( ) ; } | update the status of the model |
18,015 | public function init ( ) { $ options = $ this -> getServiceLocator ( ) -> getServiceLocator ( ) -> get ( MailOptions :: class ) ; $ emailAddresses = $ options -> getAddressList ( ) ; $ addressList = [ ] ; foreach ( $ emailAddresses as $ transport => $ address ) { $ addressList [ ] = [ 'label' => $ address [ 'name' ] . ' <' . $ address [ 'address' ] . '>' , 'value' => $ transport , ] ; } $ this -> setValueOptions ( $ addressList ) ; } | Set up value options |
18,016 | public function indexAction ( $ page , $ sort , $ direction ) { $ breadcumbs = $ this -> container -> get ( 'bacon_breadcrumbs' ) ; $ breadcumbs -> addItem ( array ( 'title' => 'Language' , 'route' => '' , ) ) ; $ breadcumbs -> addItem ( array ( 'title' => 'List' , 'route' => '' , ) ) ; $ entity = new Language ( ) ; $ query = $ this -> getDoctrine ( ) -> getRepository ( 'BaconLanguageBundle:Language' ) -> getQueryPagination ( $ entity , $ sort , $ direction ) ; if ( $ this -> get ( 'session' ) -> has ( 'language_search_session' ) ) { $ objSerialize = $ this -> get ( 'session' ) -> get ( 'language_search_session' ) ; $ entity = unserialize ( $ objSerialize ) ; $ query = $ this -> getDoctrine ( ) -> getRepository ( 'BaconLanguageBundle:Language' ) -> getQueryPagination ( $ entity , $ sort , $ direction ) ; } $ paginator = $ this -> getPagination ( $ query , $ page , Language :: PER_PAGE ) ; $ paginator -> setUsedRoute ( 'admin_language_pagination' ) ; $ form = $ this -> createForm ( new LanguageFormType ( ) , $ entity , array ( 'search' => true , ) ) ; return array ( 'pagination' => $ paginator , 'form_search' => $ form -> createView ( ) , 'form_delete' => $ this -> createDeleteForm ( ) -> createView ( ) , ) ; } | Lists all Language entities . |
18,017 | public function searchAction ( Request $ request ) { $ this -> get ( 'session' ) -> remove ( 'language_search_session' ) ; if ( $ request -> getMethod ( ) === Request :: METHOD_POST ) { $ form = $ this -> createForm ( new LanguageFormType ( ) , new Language ( ) , array ( 'search' => true , ) ) ; $ form -> handleRequest ( $ request ) ; $ this -> get ( 'session' ) -> set ( 'language_search_session' , serialize ( $ form -> getData ( ) ) ) ; } return $ this -> redirect ( $ this -> generateUrl ( 'admin_language' ) ) ; } | Search filter Language entities . |
18,018 | public function newAction ( ) { $ breadcumbs = $ this -> container -> get ( 'bacon_breadcrumbs' ) ; $ breadcumbs -> addItem ( array ( 'title' => 'Language' , 'route' => 'admin_language' , ) ) ; $ breadcumbs -> addItem ( array ( 'title' => 'New' , 'route' => '' , ) ) ; $ form = $ this -> createForm ( new LanguageFormType ( ) , new Language ( ) ) ; return array ( 'form' => $ form -> createView ( ) , ) ; } | Displays a form to create a new Language entity . |
18,019 | public function createAction ( Request $ request ) { $ breadcumbs = $ this -> container -> get ( 'bacon_breadcrumbs' ) ; $ breadcumbs -> addItem ( array ( 'title' => 'Language' , 'route' => 'admin_language' , ) ) ; $ breadcumbs -> addItem ( array ( 'title' => 'New' , 'route' => '' , ) ) ; $ form = $ this -> createForm ( new LanguageFormType ( ) , new Language ( ) ) ; $ handler = new LanguageFormHandler ( $ form , $ request , $ this -> getDoctrine ( ) -> getManager ( ) , $ this -> get ( 'session' ) -> getFlashBag ( ) ) ; if ( $ handler -> save ( ) ) { return $ this -> redirect ( $ this -> generateUrl ( 'admin_language' ) ) ; } return array ( 'form' => $ form -> createView ( ) , ) ; } | Creates a new Language entity . |
18,020 | public function editAction ( $ id ) { $ breadcumbs = $ this -> container -> get ( 'bacon_breadcrumbs' ) ; $ breadcumbs -> addItem ( array ( 'title' => 'Language' , 'route' => 'admin_language' , ) ) ; $ breadcumbs -> addItem ( array ( 'title' => 'Edit' , 'route' => '' , ) ) ; $ entity = $ this -> getDoctrine ( ) -> getRepository ( 'BaconLanguageBundle:Language' ) -> find ( $ id ) ; if ( ! $ entity ) { $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'message' , array ( 'type' => 'error' , 'message' => 'The registry not Found' , ) ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_language' ) ) ; } $ form = $ this -> createForm ( new LanguageFormType ( ) , $ entity ) ; $ deleteForm = $ this -> createDeleteForm ( $ id ) ; return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; } | Displays a form to edit an existing Language entity . |
18,021 | public function updateAction ( Request $ request , $ id ) { $ breadcumbs = $ this -> container -> get ( 'bacon_breadcrumbs' ) ; $ breadcumbs -> addItem ( array ( 'title' => 'Language' , 'route' => 'admin_language' , ) ) ; $ breadcumbs -> addItem ( array ( 'title' => 'Edit' , 'route' => '' , ) ) ; $ entity = $ this -> getDoctrine ( ) -> getRepository ( 'BaconLanguageBundle:Language' ) -> find ( $ id ) ; if ( ! $ entity ) { $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'message' , array ( 'type' => 'error' , 'message' => 'Registry not Found' , ) ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_language' ) ) ; } $ form = $ this -> createForm ( new LanguageFormType ( ) , $ entity ) ; $ deleteForm = $ this -> createDeleteForm ( $ id ) ; $ handler = new LanguageFormHandler ( $ form , $ request , $ this -> getDoctrine ( ) -> getManager ( ) , $ this -> get ( 'session' ) -> getFlashBag ( ) ) ; if ( $ handler -> save ( ) ) { return $ this -> redirect ( $ this -> generateUrl ( 'admin_language' ) ) ; } return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; } | Edits an existing Language entity . |
18,022 | public function showAction ( $ id ) { $ breadcumbs = $ this -> container -> get ( 'bacon_breadcrumbs' ) ; $ breadcumbs -> addItem ( array ( 'title' => 'Language' , 'route' => 'admin_language' , ) ) ; $ breadcumbs -> addItem ( array ( 'title' => 'Details' , 'route' => '' , ) ) ; $ entity = $ this -> getDoctrine ( ) -> getRepository ( 'BaconLanguageBundle:Language' ) -> find ( $ id ) ; if ( ! $ entity ) { $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'message' , array ( 'type' => 'error' , 'message' => 'The registry not Found' , ) ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_language' ) ) ; } $ deleteForm = $ this -> createDeleteForm ( $ id ) ; return array ( 'entity' => $ entity , 'delete_form' => $ deleteForm -> createView ( ) , ) ; } | Finds and displays a Language entity . |
18,023 | public function deleteAction ( Request $ request , $ id ) { $ handler = new LanguageFormHandler ( $ this -> createDeleteForm ( ) , $ request , $ this -> get ( 'doctrine' ) -> getManager ( ) , $ this -> get ( 'session' ) -> getFlashBag ( ) ) ; $ entity = $ this -> getDoctrine ( ) -> getRepository ( 'BaconLanguageBundle:Language' ) -> find ( $ id ) ; if ( $ handler -> delete ( $ entity ) ) { return $ this -> redirect ( $ this -> generateUrl ( 'admin_language' ) ) ; } return $ this -> redirect ( $ this -> generateUrl ( 'admin_language_show' , array ( 'id' => $ id ) ) ) ; } | Deletes a Language entity . |
18,024 | protected static function get ( $ script , $ openTag ) { $ data = Strings :: splite ( $ script , $ openTag ) ; $ output = '' ; for ( $ i = 1 ; $ i < Collection :: count ( $ data ) ; $ i ++ ) { $ next = Strings :: splite ( $ data [ $ i ] , self :: $ endOpenTag ) ; $ rest = '' ; for ( $ j = 0 ; $ j < Collection :: count ( $ next ) ; $ j ++ ) { $ rest .= $ next [ $ j ] . "\n" ; } $ next = Strings :: splite ( $ rest , self :: $ closeTag ) ; $ output = $ next [ 0 ] ; } return $ output ; } | Complie the opening tag . |
18,025 | public static function get ( $ file ) { $ type = str_replace ( 'image/' , NULL , Singleton :: class ( 'ZN\Helpers\Mime' ) -> type ( $ file ) ) ; return $ type === 'jpg' ? 'jpeg' : $ type ; } | Finder mime type . |
18,026 | protected function getRedirect ( ) : Redirect { $ context = Context :: getInstance ( ) ; $ redirect = new Redirect ( $ context -> getUrl ( $ context -> getParameter ( 'controller_path' ) ) ) ; return $ redirect ; } | Get an instance of the Redirect object that is setup with this controller as its base URL . |
18,027 | protected function getActionUrl ( $ action ) : string { $ context = Context :: getInstance ( ) ; return $ context -> getUrl ( $ context -> getParameter ( 'controller_path' ) . $ action ) ; } | Returns a URL to an action in this controller . |
18,028 | public static function hasStringKeys ( $ value , $ allowEmpty = false ) { if ( ! is_array ( $ value ) ) { return false ; } if ( ! $ value ) { return $ allowEmpty ; } return count ( array_filter ( array_keys ( $ value ) , 'is_string' ) ) > 0 ; } | Test whether an array contains one or more string keys |
18,029 | public static function hasIntegerKeys ( $ value , $ allowEmpty = false ) { if ( ! is_array ( $ value ) ) { return false ; } if ( ! $ value ) { return $ allowEmpty ; } return count ( array_filter ( array_keys ( $ value ) , 'is_int' ) ) > 0 ; } | Test whether an array contains one or more integer keys |
18,030 | public static function hasNumericKeys ( $ value , $ allowEmpty = false ) { if ( ! is_array ( $ value ) ) { return false ; } if ( ! $ value ) { return $ allowEmpty ; } return count ( array_filter ( array_keys ( $ value ) , 'is_numeric' ) ) > 0 ; } | Test whether an array contains one or more numeric keys . |
18,031 | public static function isList ( $ value , $ allowEmpty = false ) { if ( ! is_array ( $ value ) ) { return false ; } if ( ! $ value ) { return $ allowEmpty ; } return ( array_values ( $ value ) === $ value ) ; } | Test whether an array is a list |
18,032 | public static function isHashTable ( $ value , $ allowEmpty = false ) { if ( ! is_array ( $ value ) ) { return false ; } if ( ! $ value ) { return $ allowEmpty ; } return ( array_values ( $ value ) !== $ value ) ; } | Test whether an array is a hash table . |
18,033 | public static function inArray ( $ needle , array $ haystack , $ strict = false ) { if ( ! $ strict ) { if ( is_int ( $ needle ) || is_float ( $ needle ) ) { $ needle = ( string ) $ needle ; } if ( is_string ( $ needle ) ) { foreach ( $ haystack as & $ h ) { if ( is_int ( $ h ) || is_float ( $ h ) ) { $ h = ( string ) $ h ; } } } } return in_array ( $ needle , $ haystack , $ strict ) ; } | Checks if a value exists in an array . |
18,034 | public static function iteratorToArray ( $ iterator , $ recursive = true ) { if ( ! is_array ( $ iterator ) && ! $ iterator instanceof Traversable ) { throw new Exception \ InvalidArgumentException ( __METHOD__ . ' expects an array or Traversable object' ) ; } if ( ! $ recursive ) { if ( is_array ( $ iterator ) ) { return $ iterator ; } return iterator_to_array ( $ iterator ) ; } if ( method_exists ( $ iterator , 'toArray' ) ) { return $ iterator -> toArray ( ) ; } $ array = [ ] ; foreach ( $ iterator as $ key => $ value ) { if ( is_scalar ( $ value ) ) { $ array [ $ key ] = $ value ; continue ; } if ( $ value instanceof Traversable ) { $ array [ $ key ] = static :: iteratorToArray ( $ value , $ recursive ) ; continue ; } if ( is_array ( $ value ) ) { $ array [ $ key ] = static :: iteratorToArray ( $ value , $ recursive ) ; continue ; } $ array [ $ key ] = $ value ; } return $ array ; } | Convert an iterator to an array . |
18,035 | public static function filter ( array $ data , $ callback , $ flag = null ) { if ( ! is_callable ( $ callback ) ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'Second parameter of %s must be callable' , __METHOD__ ) ) ; } if ( version_compare ( PHP_VERSION , '5.6.0' ) >= 0 ) { return array_filter ( $ data , $ callback , $ flag ) ; } $ output = [ ] ; foreach ( $ data as $ key => $ value ) { $ params = [ $ value ] ; if ( $ flag === static :: ARRAY_FILTER_USE_BOTH ) { $ params [ ] = $ key ; } if ( $ flag === static :: ARRAY_FILTER_USE_KEY ) { $ params = [ $ key ] ; } $ response = call_user_func_array ( $ callback , $ params ) ; if ( $ response ) { $ output [ $ key ] = $ value ; } } return $ output ; } | Compatibility Method for array_filter on <5 . 6 systems |
18,036 | public function TopMost ( ) { $ sql = Access :: SqlBuilder ( ) ; $ tblOption = RadioOption :: Schema ( ) -> Table ( ) ; $ where = $ sql -> Equals ( $ tblOption -> Field ( 'RadioField' ) , $ sql -> Value ( $ this -> radio -> GetID ( ) ) ) -> And_ ( $ sql -> IsNull ( $ tblOption -> Field ( 'Previous' ) ) ) ; return RadioOption :: Schema ( ) -> First ( $ where ) ; } | Returns the top most option |
18,037 | public function ToArray ( ) { $ result = array ( ) ; $ option = $ this -> TopMost ( ) ; while ( $ option ) { $ result [ $ option -> GetValue ( ) ] = $ option -> GetText ( ) ; $ option = $ this -> NextOf ( $ option ) ; } return $ result ; } | Gets the radio options as array |
18,038 | public function toArray ( ) { return array ( 'id' => $ this -> getId ( ) , 'title' => $ this -> getTitle ( ) , 'class' => $ this -> getClass ( ) , 'iconCls' => $ this -> getIconClass ( ) , 'data' => $ this -> getData ( ) , 'settings' => $ this -> getSettings ( ) , ) ; } | Return array representation of this portlet . |
18,039 | public function get ( $ uri , array $ parameters = [ ] , array $ headers = [ ] , string $ protocol = '1.1' ) : ResponseInterface { $ promise = $ this -> getAsync ( $ uri , $ parameters , $ headers , $ protocol ) ; $ promise -> wait ( ) ; if ( $ promise -> getState ( ) === Promise :: REJECTED ) { throw $ promise -> getException ( ) ; } return $ promise -> getResponse ( ) ; } | Sends a GET request |
18,040 | public function getAsync ( $ uri , array $ parameters = [ ] , array $ headers = [ ] , string $ protocol = '1.1' ) : Promise { $ request = $ this -> createQueryRequest ( static :: METHOD_GET , $ uri , $ parameters , $ headers , $ protocol ) ; return $ this -> sendAsync ( $ request ) ; } | Sends a GET request asynchronously |
18,041 | public function postAsync ( $ uri , array $ parameters = [ ] , ? ContentType $ contentType = null , array $ headers = [ ] , string $ protocol = '1.1' ) : Promise { $ request = $ this -> createBodyRequest ( static :: METHOD_POST , $ uri , $ parameters , $ contentType , $ headers , $ protocol ) ; return $ this -> sendAsync ( $ request ) ; } | Sends a POST request asynchronously |
18,042 | public function putAsync ( $ uri , array $ parameters = [ ] , ? ContentType $ contentType = null , array $ headers = [ ] , string $ protocol = '1.1' ) : Promise { $ request = $ this -> createBodyRequest ( static :: METHOD_PUT , $ uri , $ parameters , $ contentType , $ headers , $ protocol ) ; return $ this -> sendAsync ( $ request ) ; } | Sends a PUT request asynchronously |
18,043 | public function patchAsync ( $ uri , array $ parameters = [ ] , ? ContentType $ contentType = null , array $ headers = [ ] , string $ protocol = '1.1' ) : Promise { $ request = $ this -> createBodyRequest ( static :: METHOD_PATCH , $ uri , $ parameters , $ contentType , $ headers , $ protocol ) ; return $ this -> sendAsync ( $ request ) ; } | Sends a PATCH request asynchronously |
18,044 | public function deleteAsync ( $ uri , array $ parameters = [ ] , ? ContentType $ contentType = null , array $ headers = [ ] , string $ protocol = '1.1' ) : Promise { $ request = $ this -> createBodyRequest ( static :: METHOD_DELETE , $ uri , $ parameters , $ contentType , $ headers , $ protocol ) ; return $ this -> sendAsync ( $ request ) ; } | Sends a DELETE request asynchronously |
18,045 | protected function createQueryRequest ( string $ method , $ uri , array $ parameters = [ ] , array $ headers = [ ] , string $ protocol = '1.1' ) : RequestInterface { $ uri = $ this -> createUri ( $ uri ) ; if ( ! empty ( $ parameters ) ) { $ queryString = http_build_query ( $ parameters ) ; if ( $ uri -> getQuery ( ) === '' ) { $ uri = $ uri -> withQuery ( $ queryString ) ; } else { $ uri = $ uri -> withQuery ( $ uri -> getQuery ( ) . '&' . $ queryString ) ; } } return $ this -> createRequest ( $ method , $ uri , $ headers , null , $ protocol ) ; } | Creates a query request |
18,046 | protected function createBodyRequest ( string $ method , $ uri , array $ parameters = [ ] , ? ContentType $ contentType = null , array $ headers = [ ] , string $ protocol = '1.1' ) : RequestInterface { if ( $ contentType === null ) { $ contentType = ContentType :: fromValue ( ContentType :: FORM ) ; } $ body = null ; if ( ! empty ( $ parameters ) ) { switch ( $ contentType -> value ( ) ) { case ContentType :: FORM : $ body = http_build_query ( $ parameters ) ; break ; case ContentType :: JSON : $ body = json_encode ( $ parameters ) ; break ; default : break ; } } if ( $ body !== null ) { $ headers = array_merge ( [ 'Content-Type' => $ contentType -> value ( ) ] , $ headers ) ; } $ uri = $ this -> createUri ( $ uri ) ; $ body = $ this -> createStream ( $ body ) ; return $ this -> createRequest ( $ method , $ uri , $ headers , $ body , $ protocol ) ; } | Creates a body request |
18,047 | public static function initFromItemClass ( $ itemClass ) { $ itemMetaData = new ItemMetaData ( ) ; $ itemMetaData -> setItemClass ( $ itemClass ) ; $ contruct = new ReflectionMethod ( $ itemClass , '__construct' ) ; foreach ( $ contruct -> getParameters ( ) as $ key => $ param ) { $ itemMetaData -> setHitPosition ( $ param -> getName ( ) , $ key ) ; if ( ! $ param -> isOptional ( ) ) { $ itemMetaData -> addRequiredHit ( $ param -> getName ( ) ) ; } } return $ itemMetaData ; } | Initializes a new View instance that will hold the object - relational mapping of the class with the given name . |
18,048 | protected function validateAndCompleteEntity ( $ entityIdentifier , $ entityDefinition ) { if ( ! isset ( $ entityDefinition [ 'label' ] ) ) { throw MappingException :: requiredMapping ( $ this -> itemClass , 'label' , $ entityIdentifier ) ; } elseif ( ! settype ( $ entityDefinition [ 'label' ] , 'string' ) ) { throw MappingException :: invalidMappingType ( $ this -> itemClass , 'label' , 'string' , $ entityIdentifier ) ; } else { $ this -> entityLabels [ $ entityIdentifier ] = $ entityDefinition [ 'label' ] ; } if ( ! isset ( $ entityDefinition [ 'entityClass' ] ) ) { throw MappingException :: requiredMapping ( $ this -> itemClass , 'entityClass' , $ entityIdentifier ) ; } elseif ( ! settype ( $ entityDefinition [ 'entityClass' ] , 'string' ) ) { throw MappingException :: invalidMappingType ( $ this -> itemClass , 'entityClass' , 'string' , $ entityIdentifier ) ; } else { $ this -> entityClasses [ $ entityIdentifier ] = $ entityDefinition [ 'entityClass' ] ; } } | Validates & completes the given entity definition . |
18,049 | protected function validateAndCompleteHit ( $ hitIdentifier , array & $ hitDefinition ) { $ this -> addRequiredHit ( $ hitIdentifier ) ; if ( ! isset ( $ hitDefinition [ 'scoreFactor' ] ) ) { $ this -> setHitScoreFactor ( $ hitIdentifier , 1 ) ; } elseif ( ! settype ( $ hitDefinition [ 'scoreFactor' ] , 'integer' ) ) { throw MappingException :: invalidMappingType ( $ this -> itemClass , 'scoreFactor' , 'integer' , $ hitIdentifier ) ; } else { $ this -> setHitScoreFactor ( $ hitIdentifier , $ hitDefinition [ 'scoreFactor' ] ) ; } if ( isset ( $ hitDefinition [ 'sortable' ] ) && ! settype ( $ hitDefinition [ 'sortable' ] , 'boolean' ) ) { throw MappingException :: invalidMappingType ( $ this -> itemClass , 'sortable' , 'boolean' , $ hitIdentifier ) ; } elseif ( isset ( $ hitDefinition [ 'sortable' ] ) && $ hitDefinition [ 'sortable' ] === true ) { $ this -> addSortableHit ( $ hitIdentifier ) ; } if ( ! isset ( $ hitDefinition [ 'label' ] ) ) { throw MappingException :: requiredMapping ( $ this -> itemClass , 'label' , $ hitIdentifier ) ; } elseif ( ! settype ( $ hitDefinition [ 'label' ] , 'string' ) ) { throw MappingException :: invalidMappingType ( $ this -> itemClass , 'label' , 'string' , $ hitIdentifier ) ; } else { $ this -> hitLabels [ $ hitIdentifier ] = $ hitDefinition [ 'label' ] ; } foreach ( $ hitDefinition [ 'mapping' ] as $ entityIdentifier => $ attribute ) { $ this -> setHitEntityAttribute ( $ hitIdentifier , $ entityIdentifier , $ attribute ) ; } } | Validates & completes the given hit definition . |
18,050 | public function getOrderedRequiredHits ( ) { $ hitIdentifiers = array ( ) ; foreach ( $ this -> requiredHits as $ hitIdentifier ) { $ hitIdentifiers [ $ this -> hitPositions [ $ hitIdentifier ] ] = $ hitIdentifier ; } krsort ( $ hitIdentifiers ) ; return $ hitIdentifiers ; } | Get required hits names ordered by item constructor positions |
18,051 | public function addRequiredHit ( $ hitIdentifier ) { if ( ! in_array ( $ hitIdentifier , $ this -> requiredHits ) ) { $ this -> requiredHits [ ] = $ hitIdentifier ; } return $ this ; } | Add Required Hit |
18,052 | public function addSortableHit ( $ hitIdentifier ) { if ( ! in_array ( $ hitIdentifier , $ this -> sortableHits ) ) { $ this -> sortableHits [ ] = $ hitIdentifier ; } return $ this ; } | Add sortable hit . |
18,053 | public function getHitEntityAttribute ( $ hitIdentifier , $ entityIdentifier ) { return isset ( $ this -> entityHitMapping [ $ entityIdentifier ] [ $ hitIdentifier ] ) ? $ this -> entityHitMapping [ $ entityIdentifier ] [ $ hitIdentifier ] : null ; } | Get hit entity attribute return null if there is no mapping for this hit |
18,054 | public function setHitEntityAttribute ( $ hitIdentifier , $ entityIdentifier , $ attribute ) { if ( ! array_key_exists ( $ entityIdentifier , $ this -> entityClasses ) ) { throw MappingException :: invalidEntity ( $ this -> itemClass , $ entityIdentifier ) ; } $ this -> entityHitMapping [ $ entityIdentifier ] [ $ hitIdentifier ] = $ attribute ; return $ this ; } | Set hit entity attribute |
18,055 | public function getFunctions ( ) { return array ( 'mesd_jasper_reportviewer_stored_report_link' => new \ Twig_Function_Method ( $ this , 'renderStoredReportLink' , array ( 'is_safe' => array ( 'html' ) ) ) , 'mesd_jasper_reportviewer_report_link' => new \ Twig_Function_Method ( $ this , 'renderReportLink' , array ( 'is_safe' => array ( 'html' ) ) ) , 'mesd_jasper_reportviewer_home' => new \ Twig_Function_Method ( $ this , 'renderReportHome' , array ( 'is_safe' => array ( 'html' ) ) ) , 'mesd_jasper_reportviewer_uri' => new \ Twig_Function_Method ( $ this , 'renderReportURI' , array ( 'is_safe' => array ( 'html' ) ) ) , 'mesd_jasper_reportviewer_direct_link' => new \ Twig_Function_Method ( $ this , 'renderDirectReportLink' , array ( 'is_safe' => array ( 'html' ) ) ) ) ; } | Get functions lists the functions in this class |
18,056 | public function renderReportHome ( $ linkText , $ classes = ' ' , $ openInNewTab = true ) { return $ this -> environment -> render ( 'MesdJasperReportViewerBundle:Partials:reportHome.html.twig' , array ( 'linkText' => $ linkText , 'classes' => $ classes , 'openInNewTab' => $ openInNewTab ) ) ; } | Render a link to the report viewer home |
18,057 | public function renderReportLink ( $ reportUri , $ linkText , $ classes = ' ' , $ openInNewTab = true , $ hideHome = true ) { return $ this -> environment -> render ( 'MesdJasperReportViewerBundle:Partials:reportLink.html.twig' , array ( 'reportUri' => $ reportUri , 'linkText' => $ linkText , 'classes' => $ classes , 'openInNewTab' => $ openInNewTab , 'hideHome' => $ hideHome ) ) ; } | Renders a link to a report |
18,058 | public function renderStoredReportLink ( $ reportUri , $ requestId , $ linkText , $ classes = ' ' , $ openInNewTab = true , $ hideHome = true ) { return $ this -> environment -> render ( 'MesdJasperReportViewerBundle:Partials:storedReportLink.html.twig' , array ( 'reportUri' => $ reportUri , 'requestId' => $ requestId , 'linkText' => $ linkText , 'classes' => $ classes , 'openInNewTab' => $ openInNewTab , 'hideHome' => $ hideHome ) ) ; } | Renders a link to a stored report |
18,059 | public function renderDirectReportLink ( ReportInstance $ reportInstance , $ linkText , $ classes = ' ' , $ openInNewTab = true , $ hideHome = true ) { return $ this -> environment -> render ( 'MesdJasperReportViewerBundle:Partials:directReportLink.html.twig' , array ( 'reportUri' => $ reportInstance -> getReportUri ( ) , 'parameters' => urlencode ( serialize ( $ reportInstance -> getParameters ( ) ) ) , 'linkText' => $ linkText , 'classes' => $ classes , 'openInNewTab' => $ openInNewTab , 'hideHome' => $ hideHome ) ) ; } | Renders a report immediately in the viewer with the parameters from the report instance object |
18,060 | public static function createFromLock ( string $ name , array $ packageData ) : PackageContract { $ keyToFunctionMappers = [ 'parent' => 'setParentName' , 'is-dev' => 'setIsDev' , 'url' => 'setUrl' , 'operation' => 'setOperation' , 'type' => 'setType' , 'requires' => 'setRequires' , 'automatic-extra' => 'setConfig' , 'autoload' => 'setAutoload' , 'created' => 'setTime' , ] ; $ package = new static ( $ name , $ packageData [ 'version' ] ) ; foreach ( $ packageData as $ key => $ data ) { if ( $ data !== null && isset ( $ keyToFunctionMappers [ $ key ] ) ) { $ package -> { $ keyToFunctionMappers [ $ key ] } ( $ data ) ; } } return $ package ; } | Create a automatic package from the lock data . |
18,061 | public function getRunner ( ) { if ( $ this -> runner ) return $ this -> runner ; $ runner = new Runner \ PHPSpecRunner ( ) ; $ this -> application -> getContainer ( ) -> injectDependency ( $ runner ) ; $ runner -> initialize ( ) ; return $ this -> runner = $ runner ; } | get runner . |
18,062 | protected function renderAttributes ( ) { $ output = '' ; foreach ( $ this -> _attr as $ key => $ value ) { $ output .= $ key . ' = "' . $ value . '" ' ; } return $ output ; } | Renders the attribute string for the element . |
18,063 | public function getAttribute ( $ key ) { return isset ( $ this -> _attr [ $ key ] ) ? $ this -> _attr [ $ key ] : null ; } | Returns the requested attribute if it exists . |
18,064 | public function isPipe ( ) { if ( \ is_null ( $ this -> isPipe ) ) { $ this -> isPipe = false ; if ( $ this -> isAttached ( ) ) { $ mode = fstat ( $ this -> stream ) [ 'mode' ] ; $ this -> isPipe = ( $ mode & 0010000 ) !== 0 ; } } return $ this -> isPipe ; } | Is the stream is a pipe? |
18,065 | public function enableAutofocus ( ) { static $ enabled = false ; if ( ! $ enabled ) { $ script = "$(document).ready(function(){" . "\$(this).find('[autofocus]:first').focus();" . "});" ; $ this -> registerScript ( $ script ) ; $ enabled = true ; } return $ this ; } | Activate focus on elements with the attribute autofocus |
18,066 | public static function to ( $ path , array $ data = null ) { ( $ data !== null ) ? self :: with ( $ data ) : '' ; $ path = ( self :: $ query_string === null ) ? Url :: link ( $ path ) : Url :: link ( $ path ) . '?' . self :: $ query_string ; header ( 'Location: ' . $ path ) ; exit ( ) ; } | This method redirect to the specified page |
18,067 | public function do ( String $ app = NULL , $ key , String $ data = NULL ) : Bool { return ( new Insert ) -> do ( $ app , $ key , $ data ) ; } | Updates language key |
18,068 | public function vlanTypes ( $ translate = false ) { $ states = $ this -> getSNMP ( ) -> walk1d ( self :: OID_VLAN_MEMBERSHIP_VLAN_TYPE ) ; if ( ! $ translate ) { return $ states ; } return $ this -> getSNMP ( ) -> translate ( $ states , self :: $ VLAN_MEMBERSHIP_VLAN_TYPES ) ; } | Get an array of the type of VLAN membership of each device port . |
18,069 | public function portStatus ( $ translate = false ) { $ states = $ this -> getSNMP ( ) -> walk1d ( self :: OID_VLAN_MEMBERSHIP_PORT_STATUS ) ; if ( ! $ translate ) { return $ states ; } return $ this -> getSNMP ( ) -> translate ( $ states , self :: $ VLAN_MEMBERSHIP_PORT_STATUS ) ; } | Get an array of the current status of VLAN in each device port . |
18,070 | private function getSubtree ( TreeExpression $ expr ) { foreach ( $ expr -> getChildren ( ) as $ child ) { if ( $ child -> getType ( ) == $ this -> operator ) return $ child ; } $ expr -> addChild ( $ subtree = new TreeExpression ( $ this -> operator ) ) ; return $ subtree ; } | Retrieve or create the first subtree that matches with the operator |
18,071 | public static function filterThemesBootstrap ( $ themesRootPath = 'themes' , $ bootstrapPathFile = 'src\\Bootstrap' , $ bootstrapPathPattern = '{theme-path}\\{bootstrap-path-file}' ) { if ( static :: $ _themeBootstraps === null ) { static :: $ _themeBootstraps = static :: findThemeBootstraps ( $ themesRootPath , $ bootstrapPathFile , $ bootstrapPathPattern ) ; } foreach ( ThemeManager :: getThemes ( ) as $ theme ) { $ themeBootstrapClass = $ theme [ 'namespace' ] . '\\Bootstrap' ; $ key = array_search ( $ themeBootstrapClass , static :: $ _themeBootstraps ) ; if ( $ key !== false ) { array_splice ( static :: $ _themeBootstraps , $ key , 1 ) ; } } Yii :: $ app -> bootstrap = array_merge ( Yii :: $ app -> bootstrap , static :: $ _themeBootstraps ) ; } | Filters bootstraps in themes folder . |
18,072 | public static function findThemeBootstraps ( $ themesRootPath , $ bootstrapPathFile , $ bootstrapPathPattern ) { $ dir = Yii :: getAlias ( '@' . $ themesRootPath ) ; if ( ! is_dir ( $ dir ) ) { throw new InvalidParamException ( "The dir argument must be a directory: $dir" ) ; } $ dir = rtrim ( $ dir , DIRECTORY_SEPARATOR ) ; $ list = [ ] ; $ handle = opendir ( $ dir ) ; if ( $ handle === false ) { throw new InvalidParamException ( "Unable to open directory: $dir" ) ; } while ( ( $ file = readdir ( $ handle ) ) !== false ) { if ( $ file === '.' || $ file === '..' ) { continue ; } $ path = $ dir . DIRECTORY_SEPARATOR . $ file ; if ( is_dir ( $ path ) ) { list ( $ r , $ p ) = static :: formatBootstrapPath ( $ bootstrapPathPattern , $ file , $ bootstrapPathFile ) ; if ( is_file ( $ dir . DIRECTORY_SEPARATOR . $ p ) ) { $ list [ ] = $ themesRootPath . '\\' . $ r ; continue ; } } } closedir ( $ handle ) ; return $ list ; } | Finds all Bootstrap class files in the given themes root path . |
18,073 | public function guessFromCurrent ( ) { $ this -> setUrl ( UrlHelper :: getRequestUrl ( ) ) -> setProtocol ( UrlHelper :: getHttpProtocol ( ) ) -> setMethod ( $ _SERVER [ 'REQUEST_METHOD' ] ) -> setHeaders ( $ this -> getallheaders ( ) ) -> setArguments ( isset ( $ _GET ) ? $ _GET : array ( ) ) -> setData ( isset ( $ _POST ) ? $ _POST : array ( ) ) -> setSession ( isset ( $ _SESSION ) ? $ _SESSION : array ( ) ) -> setFiles ( isset ( $ _FILES ) ? $ _FILES : array ( ) ) -> setCookies ( isset ( $ _COOKIE ) ? $ _COOKIE : array ( ) ) -> setAuthenticationUser ( isset ( $ _SERVER [ 'PHP_AUTH_USER' ] ) ? $ _SERVER [ 'PHP_AUTH_USER' ] : null ) -> setAuthenticationPassword ( isset ( $ _SERVER [ 'PHP_AUTH_PW' ] ) ? $ _SERVER [ 'PHP_AUTH_PW' ] : null ) -> setAuthenticationType ( ! empty ( $ _SERVER [ 'PHP_AUTH_DIGEST' ] ) ? 'digest' : 'basic' ) ; return $ this ; } | Populate the request object with current HTTP request values |
18,074 | protected function _extractSegments ( & $ arguments ) { if ( is_string ( $ arguments ) ) $ this -> _extractArguments ( $ arguments ) ; foreach ( $ arguments as $ var => $ val ) { if ( empty ( $ val ) && strpos ( $ var , '/' ) !== false ) { $ parts = explode ( '/' , $ var ) ; unset ( $ arguments [ $ var ] ) ; $ index = null ; foreach ( $ parts as $ part ) { if ( is_null ( $ index ) ) { $ index = $ part ; } else { $ arguments [ $ index ] = $ part ; $ index = null ; } } } } } | Extract the table of var = > val arguments pairs from a slashed route |
18,075 | public static function cleanArgument ( $ arg_value , $ flags = ENT_COMPAT , $ encoding = 'UTF-8' ) { if ( is_string ( $ arg_value ) ) { $ result = stripslashes ( htmlspecialchars ( $ arg_value , ENT_COMPAT , $ encoding ) ) ; } elseif ( is_array ( $ arg_value ) ) { $ result = array ( ) ; foreach ( $ arg_value as $ arg => $ value ) { $ result [ $ arg ] = self :: cleanArgument ( $ value , $ flags , $ encoding ) ; } } return $ result ; } | Clean the value taken from request arguments or data |
18,076 | public function find_all_files ( $ dir ) { $ root = array_reverse ( scandir ( $ dir ) ) ; if ( count ( $ root ) == 0 ) return ; foreach ( $ root as $ value ) { if ( $ value === '.' || $ value === '..' ) { continue ; } if ( is_file ( "$dir/$value" ) ) { $ result [ ] = "$dir/$value" ; $ this -> posts [ ] = $ this -> read ( "$dir/$value" , $ value ) ; continue ; } foreach ( $ this -> find_all_files ( "$dir/$value" ) as $ value ) { $ result [ ] = $ value ; } } return $ result ; } | Find All file on asset dir and create array of Model \ Post |
18,077 | public function defineAuthor ( $ header ) { $ author = $ this -> config [ 'authors' ] [ $ header [ 'author' ] ] ; return new Author ( $ header [ 'author' ] , $ author [ 'name' ] , $ author [ 'email' ] , $ author [ 'signature' ] , $ author [ 'facebook' ] , $ author [ 'twitter' ] , $ author [ 'github' ] ) ; } | Create new Author object instance for Post object |
18,078 | public function defineCategories ( $ header ) { $ categories = array ( ) ; $ cats = explode ( ',' , $ header [ 'categories' ] ) ; foreach ( $ cats as $ category ) { $ categories [ ] = new Category ( trim ( $ category ) ) ; } return $ categories ; } | Create a list of category from header metadata |
18,079 | public function run ( ) { try { $ request = $ this -> getLoops ( ) -> getService ( "request" ) ; $ response = $ this -> getLoops ( ) -> getService ( "response" ) ; $ web_core = $ this -> getLoops ( ) -> getService ( "web_core" ) ; echo $ web_core -> dispatch ( $ this -> url , $ request , $ response ) ; } catch ( Throwable $ exception ) { http_response_code ( 500 ) ; try { $ renderer = $ this -> getLoops ( ) -> getService ( "renderer" ) ; echo $ renderer -> render ( $ exception ) ; } catch ( Throwable $ render_exception ) { Misc :: displayException ( $ exception ) ; } } } | Runs the request by by dispaching the request via the web core service . This method will print the resulting output and set http status codes accordingly . Exceptions will be caught and rendered . |
18,080 | public static function encode ( $ string , $ oneLine = true ) { if ( ! self :: isEncoded ( $ string ) ) { $ string = base64_encode ( $ string ) ; } if ( $ string && $ oneLine ) { $ string = str_replace ( [ "\r" , "\n" ] , '' , $ string ) ; } return $ string ; } | Encodes the specified string as Base64 . Note that a previously - encoded string will not be re - encoded . |
18,081 | protected function throwNewInvalidArgumentException ( $ errorMsg ) { $ selfClass = version_compare ( PHP_VERSION , '5.5' , '>' ) ? self :: class : __CLASS__ ; $ str = '[' . $ selfClass . '] ' . $ errorMsg . ' (' . 'form id: `' . $ this -> id . '`, ' . 'form type: `' . get_class ( $ this -> form ) . '`' . ')' ; throw new \ InvalidArgumentException ( $ str ) ; } | Throw new \ InvalidArgumentException with given error message and append automatically current class name current form id and form class type . |
18,082 | public function PreDispatch ( ) { if ( $ this -> dispatchState > 1 ) return $ this ; parent :: PreDispatch ( ) ; foreach ( $ this -> fields as $ field ) $ field -> PreDispatch ( ) ; $ session = & $ this -> getSession ( ) ; foreach ( $ session -> errors as $ errorMsgAndFieldNames ) { list ( $ errorMsg , $ fieldNames ) = array_merge ( [ ] , $ errorMsgAndFieldNames ) ; $ this -> AddError ( $ errorMsg , $ fieldNames ) ; } if ( $ session -> values ) { foreach ( $ session -> values as $ fieldName => $ fieldValue ) { $ field = $ this -> fields [ $ fieldName ] ; if ( $ field -> GetValue ( ) === NULL ) $ field -> SetValue ( $ fieldValue ) ; } } $ viewClass = $ this -> viewClass ; $ this -> view = $ viewClass :: CreateInstance ( ) -> SetForm ( $ this ) ; if ( $ this -> viewScript ) $ this -> view -> SetController ( $ this -> parentController ) -> SetView ( $ this -> parentController -> GetView ( ) ) ; $ this -> dispatchState = 2 ; return $ this ; } | Prepare form and it s fields for rendering . |
18,083 | public function onBeforeNormalization ( BeforeNormalizationEvent $ event ) : void { $ resource = $ event -> getResource ( ) ; if ( ! $ resource instanceof RelatedResourceInterface ) { return ; } $ relations = $ resource -> getRelations ( ) ; foreach ( $ relations as $ relation ) { if ( ! $ relation instanceof SymfonyGrantedRelation ) { continue ; } if ( ! $ this -> authorizationChecker -> isGranted ( $ relation -> getAttribute ( ) , $ relation -> getObject ( ) ) ) { $ resource -> removeRelation ( $ relation ) ; } } } | Check the grants to relations |
18,084 | public function addGroup ( Group $ group ) { if ( $ this -> hasGroup ( $ group ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Group "%s" is allready defined.' , $ group -> getName ( ) ) ) ; } $ this -> groups [ $ group -> getName ( ) ] = $ group ; return $ this ; } | Adds the group . |
18,085 | public function getGroupByName ( $ name ) { if ( ! array_key_exists ( $ name , $ this -> groups ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Can\'t find "%s" group.' , $ name ) ) ; } return $ this -> groups [ $ name ] ; } | Returns a group by his name . |
18,086 | public function getDefinitionByIdentifier ( $ identifier ) { foreach ( $ this -> groups as $ group ) { foreach ( $ group -> getDefinitions ( ) as $ definition ) { if ( $ definition -> getIdentifier ( ) === $ identifier ) { return $ definition ; } } } return null ; } | Returns a characteristic definition by his identifier . |
18,087 | protected function convertValue ( $ data ) { if ( $ this -> isTraversable ( $ data ) ) { return $ this -> recursiveConvertArray ( $ data ) ; } if ( is_object ( $ data ) ) { return $ this -> convertObject ( $ data ) ? : null ; } return $ data ; } | Conversts a given value into a traversable one . |
18,088 | protected function recursiveConvertArray ( $ data ) { $ out = [ ] ; foreach ( $ data as $ key => $ value ) { $ nkey = $ this -> normalize ( $ key ) ; if ( in_array ( $ nkey , $ this -> ignoredAttributes ) ) { continue ; } $ out [ $ nkey ] = is_scalar ( $ value ) ? $ value : $ this -> convertValue ( $ value ) ; } return $ out ; } | Recursivly converts a given value to an array . |
18,089 | protected function setObjectProperties ( array $ properties , $ data , array & $ out = [ ] ) { foreach ( $ properties as $ property ) { $ prop = $ property -> getName ( ) ; if ( in_array ( $ name = $ this -> normalize ( $ prop ) , $ this -> ignoredAttributes ) ) { continue ; } $ out [ $ prop ] = $ this -> getObjectPropertyValue ( $ property , $ prop , $ data ) ; } } | Set opbject properties to an output array . |
18,090 | public static function dateSQL ( $ date , $ format = 'd-m-Y' ) { if ( empty ( $ date ) ) { return null ; } $ obj = DateTime :: createFromFormat ( 'Y-m-d H:i:s' , $ date ) ; if ( empty ( $ obj ) ) { return null ; } return $ obj -> format ( $ format ) ; } | SQL timestamp to date format |
18,091 | public static function random ( $ len = 6 ) { $ chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ; $ random = '' ; for ( $ p = 0 ; $ p < $ len ; $ p ++ ) { $ random .= $ chars [ mt_rand ( 0 , 61 ) ] ; } return $ random ; } | Get random string |
18,092 | public static function lowerLabel ( $ value , array $ labels ) { ksort ( $ labels ) ; foreach ( $ labels as $ max => $ label ) { if ( $ value <= $ max ) { return $ label ; } } return end ( $ labels ) ; } | Get label that key is lower than value |
18,093 | public static function majorVersion ( $ version ) { $ components = explode ( '.' , $ version ) ; foreach ( $ components as $ key => $ value ) { if ( $ key > 0 && is_numeric ( $ value ) ) { $ components [ $ key ] = '0' ; } } return implode ( '.' , $ components ) ; } | Get major version |
18,094 | public function setDisplayer ( DisplayerInterface $ displayer ) { $ this -> displayer = $ displayer ; if ( ! isset ( $ this -> exceptionHandler ) ) return ; $ this -> exceptionHandler -> setDisplayer ( $ displayer ) ; } | Set the exception displayer |
18,095 | protected function registerExceptionHandler ( ) { $ this -> exceptionHandler = ExceptionHandler :: register ( true ) ; $ this -> exceptionHandler -> setDisplayer ( $ this -> displayer ) ; } | Register the Symfony exception handler |
18,096 | public function add ( ResourceAssemblerSupportableInterface $ supportable , ResourceAssemblerInterface $ assembler ) : void { $ this -> map [ ] = [ $ supportable , $ assembler ] ; } | Add the resource assembler to registry |
18,097 | public function setProperty ( $ key , $ value = null ) { if ( $ key instanceof Property ) { $ value = $ key ; $ key = $ key -> getName ( ) ; } elseif ( ! $ value instanceof Property ) { $ value = new Property ( $ key , $ value ) ; } foreach ( $ this -> properties as $ index => $ property ) { if ( $ property -> getName ( ) == $ key ) { unset ( $ this -> properties [ $ index ] ) ; } } $ this -> properties [ ] = $ value ; return $ this ; } | Appending a property at the end and cleaning up any property with the same name |
18,098 | public function getProperty ( $ key , & $ match = false ) { if ( is_array ( $ key ) ) { foreach ( array_reverse ( $ this -> properties ) as $ property ) { if ( in_array ( $ property -> getName ( ) , $ key ) ) { $ match = $ property -> getName ( ) ; return $ property ; } } } else { foreach ( array_reverse ( $ this -> properties ) as $ property ) { if ( $ property -> getName ( ) == $ key ) { $ match = $ key ; return $ property ; } } } return false ; } | Return the property if it is within this set otherwise retuns false |
18,099 | protected function getHttpApplication ( ServiceLocatorInterface $ serviceLocator ) : HttpApplication { $ chain = $ serviceLocator -> getService ( MiddlewareChainInterface :: class ) ; $ request = $ serviceLocator -> getService ( RequestInterface :: class ) ; return new HttpApplication ( $ chain , $ request , $ serviceLocator , $ extra [ 'modules' ] ?? [ ] ) ; } | Get HTTP application . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.