idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
48,900 | public function registerConfigData ( ) { $ authConfig = $ this -> app [ 'config' ] -> get ( 'auth' , [ ] ) ; $ this -> app [ 'config' ] -> set ( 'auth' , array_merge_recursive ( require __DIR__ . '/../config/avored-auth.php' , $ authConfig ) ) ; $ this -> mergeConfigFrom ( __DIR__ . '/../config/avored-ecommerce.php' , 'avored-ecommerce' ) ; } | Register the Config Data |
48,901 | public function publishFiles ( ) { $ this -> publishes ( [ __DIR__ . '/../config/avored-ecommerce.php' => config_path ( 'avored-ecommerce.php' ) , ] , 'config' ) ; $ this -> publishes ( [ __DIR__ . '/../config/avored-auth.php' => config_path ( 'avored-auth.php' ) , ] , 'config' ) ; $ this -> publishes ( [ __DIR__ . '/../resources/lang' => base_path ( 'themes/avored/default/lang/vendor' ) ] , 'avored-module-lang' ) ; $ this -> publishes ( [ __DIR__ . '/../resources/views' => base_path ( 'themes/avored/default/views/vendor' ) ] , 'avored-module-views' ) ; $ this -> publishes ( [ __DIR__ . '/../database/migrations' => database_path ( 'avored-migrations' ) , ] ) ; } | Register the Publish Files |
48,902 | protected function registerModelContracts ( ) { $ this -> app -> bind ( AdminUserInterface :: class , AdminUserRepository :: class ) ; $ this -> app -> bind ( MenuInterface :: class , MenuRepository :: class ) ; $ this -> app -> bind ( PageInterface :: class , PageRepository :: class ) ; $ this -> app -> bind ( RoleInterface :: class , RoleRepository :: class ) ; $ this -> app -> bind ( SiteCurrencyInterface :: class , SiteCurrencyRepository :: class ) ; } | Register the Repository Instance . |
48,903 | public function store ( Request $ request ) { $ filePath = $ this -> handleImageUpload ( $ request -> file ( 'theme_zip_file' ) ) ; $ zip = new \ ZipArchive ( ) ; if ( $ zip -> open ( $ filePath ) === true ) { $ extractPath = base_path ( 'themes' ) ; $ zip -> extractTo ( $ extractPath ) ; $ zip -> close ( ) ; } else { throwException ( 'Error in Zip Extract error.' ) ; } return redirect ( ) -> route ( 'admin.theme.index' ) ; } | Store a newly created theme in database . |
48,904 | public function store ( PropertyRequest $ request ) { $ property = Model :: create ( $ request -> all ( ) ) ; $ this -> _saveDropdownOptions ( $ property , $ request ) ; return redirect ( ) -> route ( 'admin.property.index' ) ; } | Store a newly created property in database . |
48,905 | private function _saveDropdownOptions ( $ property , $ request ) { if ( null !== $ request -> get ( 'dropdown-options' ) ) { $ property -> propertyDropdownOptions ( ) -> delete ( ) ; foreach ( $ request -> get ( 'dropdown-options' ) as $ key => $ val ) { if ( $ key == '__RANDOM_STRING__' ) { continue ; } $ property -> propertyDropdownOptions ( ) -> create ( $ val ) ; } } } | Save Property Dropdown Field options |
48,906 | public function setRows ( $ rows ) { if ( $ rows && count ( $ rows ) > 0 ) { foreach ( $ rows as $ row ) { $ this -> setRow ( $ row ) ; } } return $ this ; } | Set grid rows |
48,907 | public function getColumn ( $ column ) { if ( $ this -> columns -> has ( $ column ) ) { return $ this -> columns [ $ column ] ; } throw new ColumnException ( 'Column not found!' ) ; } | Get column by key |
48,908 | public function getFilter ( $ key , $ default_value = '' ) { if ( $ this -> filters -> has ( $ key ) ) { return $ this -> filters [ $ key ] ; } return $ default_value ; } | Get single filter by key |
48,909 | public function getFilters ( $ to_array = true ) { if ( $ to_array === true ) { return $ this -> filters -> toArray ( ) ; } return $ this -> filters ; } | Get all filters |
48,910 | public function setFilters ( $ filters = [ ] ) { if ( $ filters ) { foreach ( $ filters as $ key => $ value ) { $ this -> setFilter ( $ key , $ value ) ; } } return $ this ; } | Set many filters |
48,911 | public function hasFilters ( ) { foreach ( $ this -> columns as $ col ) { if ( $ col -> hasFilters ( ) === true ) { return true ; } } return false ; } | Check if the datagrid has filters . Will loop through all columns and if any of the columns has filters this will mean that the datagrid will have filters in general . |
48,912 | public function getSortParams ( $ field ) { $ filters = clone $ this -> getFilters ( false ) ; if ( ! $ filters -> has ( 'order_by' ) ) { $ filters -> put ( 'order_by' , '' ) ; } if ( ! $ filters -> has ( 'order_dir' ) ) { $ filters -> put ( 'order_dir' , 'ASC' ) ; } if ( $ filters [ 'order_by' ] == $ field ) { if ( ! $ filters -> has ( 'order_dir' ) || $ filters [ 'order_dir' ] == 'ASC' ) { $ filters -> put ( 'order_dir' , 'DESC' ) ; } else { $ filters -> put ( 'order_dir' , 'ASC' ) ; } } else { $ filters -> put ( 'order_by' , $ field ) ; $ filters -> put ( 'order_dir' , 'ASC' ) ; } $ per_page = intval ( \ Illuminate \ Support \ Facades \ Request :: get ( 'per_page' , \ Config :: get ( 'pagination.per_page' ) ) ) ; $ per_page = $ per_page > 0 ? $ per_page : \ Config :: get ( 'pagination.per_page' ) ; return [ 'f' => $ filters -> toArray ( ) , 'page' => 1 , 'per_page' => $ per_page ] ; } | Get array of data for sort links at the header of the grid |
48,913 | public function initPagination ( $ rows ) { if ( $ rows instanceof Paginator ) { $ this -> setPagination ( $ rows -> appends ( Request :: all ( ) ) ) ; } } | Init the grid pagination |
48,914 | public static function getCurrentRouteLink ( $ get_params = [ ] ) { $ current_action = \ Illuminate \ Support \ Facades \ Route :: current ( ) -> getAction ( ) ; $ controller = '\\' . $ current_action [ 'controller' ] ; $ parameters = \ Illuminate \ Support \ Facades \ Route :: current ( ) -> parameters ( ) ; return action ( $ controller , $ parameters ) . ( $ get_params ? '?' . http_build_query ( $ get_params ) : '' ) ; } | Current route link |
48,915 | public static function getRowInstance ( $ row ) { if ( is_array ( $ row ) ) { return new \ Aginev \ Datagrid \ Rows \ ArrayRow ( $ row ) ; } else if ( $ row instanceof Model ) { return new \ Aginev \ Datagrid \ Rows \ ModelRow ( $ row ) ; } else if ( $ row instanceof Collection ) { return new \ Aginev \ Datagrid \ Rows \ CollectionRow ( $ row ) ; } else if ( is_object ( $ row ) ) { return new \ Aginev \ Datagrid \ Rows \ ObjectRow ( $ row ) ; } throw new CellException ( 'Unsupported data!' ) ; } | Get row instance based on the data type |
48,916 | public function getKey ( $ refers_to = false ) { if ( $ refers_to === true && $ this -> refers_to !== false ) { return $ this -> refers_to ; } return $ this -> key ; } | Get column key |
48,917 | public function init ( array $ config ) { if ( $ config ) { foreach ( $ config as $ key => $ value ) { $ method = 'set' . ucfirst ( camel_case ( $ key ) ) ; if ( method_exists ( $ this , $ method ) ) { $ this -> $ method ( $ value ) ; } } } return $ this ; } | Setup column by passing config array . |
48,918 | public function getFilters ( $ first_blank = false ) { $ filters = $ this -> filters ; if ( $ first_blank ) { $ filters = [ '' => '---' ] + $ filters ; } return $ filters ; } | Get column filters |
48,919 | public function setFilters ( $ filters ) { if ( $ filters instanceof Collection ) { $ filters = $ filters -> toArray ( ) ; } $ this -> filters = $ filters ; return $ this ; } | Set column filters |
48,920 | public function merge ( Style $ style ) { if ( $ style -> getDocument ( ) == $ this -> document ) { $ this -> document = $ style -> getDocument ( ) ; } if ( $ style -> getSection ( ) == $ this -> section ) { $ this -> section = $ style -> getSection ( ) ; } if ( $ style -> getParagraph ( ) == $ this -> paragraph ) { $ this -> paragraph = $ style -> getParagraph ( ) ; } if ( $ style -> getCharacter ( ) == $ this -> character ) { $ this -> character = $ style -> getCharacter ( ) ; } return ; } | Merges two styles |
48,921 | public function read ( $ string ) { if ( ! is_string ( $ string ) ) { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter one, string, to be a string" ) ; } $ string = '{' . $ string . '}' ; $ chunker = new \ Jstewmc \ Chunker \ Text ( $ string ) ; $ stream = new \ Jstewmc \ Stream \ Stream ( $ chunker ) ; $ tokens = ( new Lexer ( ) ) -> lex ( $ stream ) ; $ group = ( new Renderer ( ) ) -> render ( ( new Parser ( ) ) -> parse ( $ tokens ) ) ; $ this -> parent = null ; $ this -> children = $ group -> getChildren ( ) ; $ this -> style = $ group -> getStyle ( ) ; $ this -> isRendered = true ; return ( bool ) $ group ; } | Reads the snippet |
48,922 | public function write ( $ format = 'rtf' ) { if ( ! is_string ( $ format ) ) { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter one, format, to be a string" ) ; } $ string = ( new Writer ( ) ) -> write ( $ this , $ format ) ; if ( $ format === 'rtf' ) { $ string = substr ( $ string , 1 , - 1 ) ; } return $ string ; } | Writes the snippet to a string |
48,923 | public function parse ( Array $ tokens ) { if ( $ this -> countGroupOpen ( $ tokens ) !== $ this -> countGroupClose ( $ tokens ) ) { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter one, tokens, to be valid RTF " . "string; however, the number of groups opened does not equal " . "the number of groups closed" ) ; } $ root = null ; $ stack = new \ SplStack ( ) ; foreach ( $ tokens as $ token ) { if ( $ token instanceof Token \ Group \ Open ) { $ this -> parseGroupOpen ( $ token , $ stack , $ root ) ; if ( $ root === null ) { $ root = $ stack -> bottom ( ) ; } } else { if ( $ stack -> count ( ) ) { if ( $ token instanceof Token \ Group \ Close ) { $ this -> parseGroupClose ( $ token , $ stack ) ; } elseif ( $ token instanceof Token \ Control \ Word ) { $ this -> parseControlWord ( $ token , $ stack -> top ( ) ) ; } elseif ( $ token instanceof Token \ Control \ Symbol ) { $ this -> parseControlSymbol ( $ token , $ stack -> top ( ) ) ; } elseif ( $ token instanceof Token \ Text ) { $ this -> parseText ( $ token , $ stack -> top ( ) ) ; } } else { } } } return $ root ; } | Parses tokens into a parse tree |
48,924 | protected function countGroupOpen ( Array $ tokens ) { return array_reduce ( $ tokens , function ( $ carry , $ item ) { return $ carry += $ item instanceof Token \ Group \ Open ; } , 0 ) ; } | Counts the number of group - open tokens |
48,925 | protected function parseControlSymbol ( Token \ Control \ Symbol $ token , Element \ Group $ group ) { if ( array_key_exists ( $ token -> getSymbol ( ) , self :: $ symbols ) ) { $ name = self :: $ symbols [ $ token -> getSymbol ( ) ] ; $ name = ucfirst ( $ name ) ; $ classname = "Jstewmc\\Rtf\\Element\\Control\\Symbol\\$name" ; if ( class_exists ( $ classname ) ) { $ symbol = new $ classname ( ) ; } else { $ symbol = new Element \ Control \ Symbol \ Symbol ( ) ; $ symbol -> setSymbol ( $ token -> getSymbol ( ) ) ; } } else { $ symbol = new Element \ Control \ Symbol \ Symbol ( ) ; $ symbol -> setSymbol ( $ token -> getSymbol ( ) ) ; } $ symbol -> setParameter ( $ token -> getParameter ( ) ) ; $ symbol -> setIsSpaceDelimited ( $ token -> getIsSpaceDelimited ( ) ) ; $ symbol -> setParent ( $ group ) ; $ group -> appendChild ( $ symbol ) ; return ; } | Parses a control symbol token |
48,926 | protected function parseControlWord ( Token \ Control \ Word $ token , Element \ Group $ group ) { $ filename = ucfirst ( $ token -> getWord ( ) ) ; $ classname = "Jstewmc\\Rtf\\Element\\Control\\Word\\$filename" ; if ( class_exists ( $ classname ) ) { $ word = new $ classname ( ) ; } else { $ word = new Element \ Control \ Word \ Word ( ) ; $ word -> setWord ( $ token -> getWord ( ) ) ; } $ word -> setParameter ( $ token -> getParameter ( ) ) ; $ word -> setIsSpaceDelimited ( $ token -> getIsSpaceDelimited ( ) ) ; $ word -> setParent ( $ group ) ; $ group -> appendChild ( $ word ) ; return ; } | Parses a control word token |
48,927 | protected function parseGroupOpen ( Token \ Group \ Open $ token , \ SplStack $ stack ) { $ group = new Element \ Group ( ) ; if ( $ stack -> count ( ) > 0 ) { $ group -> setParent ( $ stack -> top ( ) ) ; $ stack -> top ( ) -> appendChild ( $ group ) ; } $ stack -> push ( $ group ) ; return ; } | Parses a group - open token |
48,928 | protected function parseText ( Token \ Text $ token , Element \ Group $ group ) { $ text = new Element \ Text ( $ token -> getText ( ) ) ; $ text -> setParent ( $ group ) ; $ group -> appendChild ( $ text ) ; return ; } | Parses a text token |
48,929 | public function appendChild ( Element $ element ) { $ this -> beforeInsert ( $ element ) ; array_push ( $ this -> children , $ element ) ; $ this -> afterInsert ( ) ; return $ this ; } | Appends a child element to this group |
48,930 | public function hasChild ( $ one , $ two = null ) { $ hasChild = false ; $ isOneElement = $ one instanceof Element ; $ isOneIndex = is_numeric ( $ one ) && is_int ( + $ one ) ; if ( $ isOneElement || $ isOneIndex ) { $ isTwoNull = $ two === null ; $ isTwoElement = $ two instanceof Element ; $ isTwoIndex = is_numeric ( $ two ) && is_int ( + $ two ) ; if ( $ isTwoNull || $ isTwoElement || $ isTwoIndex ) { if ( $ isOneElement && $ isTwoNull ) { $ hasChild = $ this -> getChildIndex ( $ one ) !== false ; } elseif ( $ isOneElement && $ isTwoIndex ) { $ hasChild = $ this -> getChildIndex ( $ one ) === $ two ; } elseif ( $ isOneIndex && $ isTwoNull ) { $ hasChild = array_key_exists ( $ one , $ this -> children ) && ! empty ( $ this -> children [ $ one ] ) ; } elseif ( $ isOneIndex && $ isTwoElement ) { $ hasChild = $ this -> getChildIndex ( $ two ) === $ one ; } else { throw new \ BadMethodCallException ( __METHOD__ . "() expects one or two parameters: an element, an index, or both " . "(in any order)" ) ; } } else { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter two to be null, Element, or integer" ) ; } } else { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter one to be an Element or integer" ) ; } return $ hasChild ; } | Returns true if the group has the child |
48,931 | public function render ( ) { $ this -> isRendered = false ; foreach ( $ this -> children as $ k => $ child ) { if ( $ k == 0 ) { $ style = $ this -> style ; } else { $ previous = $ this -> children [ $ k - 1 ] ; $ style = $ previous -> getStyle ( ) ; } $ child -> setStyle ( clone $ style ) ; if ( $ child instanceof Group ) { $ child -> render ( ) ; } elseif ( $ child instanceof Control \ Control ) { $ child -> run ( ) ; } $ child -> getStyle ( ) -> merge ( $ style ) ; } $ this -> isRendered = true ; return ; } | Renders the group |
48,932 | public function prependChild ( Element $ element ) { $ this -> beforeInsert ( $ element ) ; array_unshift ( $ this -> children , $ element ) ; $ this -> afterInsert ( ) ; return $ this ; } | Prepends a child element to the group |
48,933 | public function toHtml ( ) { $ html = '' ; if ( ! $ this -> isDestination ( ) ) { $ oldStyle = $ this -> style ; $ isFirstGroup = empty ( $ this -> parent ) ; $ isFirstTextualElement = true ; foreach ( $ this -> children as $ child ) { $ string = $ child -> format ( 'html' ) ; if ( ! empty ( $ string ) ) { $ newStyle = $ child -> getStyle ( ) ; if ( $ isFirstGroup && $ isFirstTextualElement ) { $ html .= '<section style="' . $ newStyle -> getSection ( ) -> format ( 'css' ) . '">' . '<p style="' . $ newStyle -> getParagraph ( ) -> format ( 'css' ) . '">' . '<span style="' . $ newStyle -> getCharacter ( ) -> format ( 'css' ) . '">' ; $ isFirstTextualElement = false ; } else { if ( $ oldStyle -> getSection ( ) != $ newStyle -> getSection ( ) ) { $ html .= '</span></p></section>' . '<section style="' . $ newStyle -> getSection ( ) -> format ( 'css' ) . '">' . '<p style="' . $ newStyle -> getParagraph ( ) -> format ( 'css' ) . '">' . '<span style="' . $ newStyle -> getCharacter ( ) -> format ( 'css' ) . '">' ; } elseif ( $ oldStyle -> getParagraph ( ) != $ newStyle -> getParagraph ( ) ) { $ html .= '</span></p>' . '<p style="' . $ newStyle -> getParagraph ( ) -> format ( 'css' ) . '">' . '<span style="' . $ newStyle -> getCharacter ( ) -> format ( 'css' ) . '">' ; } elseif ( $ oldStyle -> getCharacter ( ) != $ newStyle -> getCharacter ( ) ) { $ html .= '</span>' . '<span style="' . $ newStyle -> getCharacter ( ) -> format ( 'css' ) . '">' ; } } $ html .= $ string ; $ oldStyle = $ newStyle ; } } } return $ html ; } | Returns the group as an html5 string |
48,934 | public function toRtf ( ) { $ rtf = '{' ; foreach ( $ this -> children as $ child ) { $ rtf .= $ child -> format ( 'rtf' ) ; } $ rtf .= '}' ; return $ rtf ; } | Returns the group as an rtf string |
48,935 | public function toText ( ) { $ text = '' ; if ( ! $ this -> isDestination ( ) ) { foreach ( $ this -> children as $ child ) { $ text .= $ child -> format ( 'text' ) ; } } return $ text ; } | Returns the group as plain text |
48,936 | public function render ( Element \ Group $ root ) { $ style = new Style ( ) ; $ root -> setStyle ( $ style ) ; $ root -> render ( ) ; return $ root ; } | Renders the parse tree into a document |
48,937 | public function load ( $ source ) { if ( ! is_string ( $ source ) ) { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter one, source, to be a string file name" ) ; } $ chunker = new \ Jstewmc \ Chunker \ File ( $ source ) ; return $ this -> create ( $ chunker ) ; } | Creates a document from a file |
48,938 | public function read ( $ string ) { if ( ! is_string ( $ string ) ) { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter one, string, to, er, be a string" ) ; } $ chunker = new \ Jstewmc \ Chunker \ Text ( $ string ) ; return $ this -> create ( $ chunker ) ; } | Creates a document from a string |
48,939 | protected function create ( \ Jstewmc \ Chunker \ Chunker $ chunker ) { $ stream = new \ Jstewmc \ Stream \ Stream ( $ chunker ) ; $ lexer = new Lexer ( ) ; $ tokens = $ lexer -> lex ( $ stream ) ; if ( ! empty ( $ tokens ) ) { $ parser = new Parser ( ) ; $ group = $ parser -> parse ( $ tokens ) ; if ( $ group !== null ) { $ renderer = new Renderer ( ) ; $ this -> root = $ renderer -> render ( $ group ) ; } else { $ this -> root = null ; } } else { $ this -> root = null ; } return ( bool ) $ this -> root ; } | Creates the document |
48,940 | public static function createFromStream ( \ Jstewmc \ Stream \ Stream $ stream ) { $ token = false ; $ text = '' ; while ( false !== ( $ character = $ stream -> current ( ) ) ) { if ( ! in_array ( $ character , [ "\n" , "\r" , "\f" , "\0" ] ) ) { if ( $ character == '\\' ) { if ( false !== ( $ next = $ stream -> next ( ) ) ) { if ( in_array ( $ next , [ '\\' , '{' , '}' ] ) ) { $ text .= $ next ; } else { $ stream -> previous ( ) ; $ stream -> previous ( ) ; break ; } } else { } } elseif ( $ character == '{' || $ character == '}' ) { $ stream -> previous ( ) ; break ; } else { $ text .= $ character ; } } $ stream -> next ( ) ; } if ( ! empty ( $ text ) || $ text === '0' ) { $ token = new Text ( $ text ) ; } return $ token ; } | Creates a new text token from a stream |
48,941 | public function lexAll ( \ Jstewmc \ Stream \ Stream $ stream ) { $ tokens = [ ] ; while ( false !== ( $ token = $ this -> lexOne ( $ stream ) ) ) { $ tokens [ ] = $ token ; } return $ tokens ; } | Lexes all tokens from the current stream |
48,942 | public function lexOne ( \ Jstewmc \ Stream \ Stream $ stream ) { $ token = false ; if ( $ stream -> hasCharacters ( ) ) { switch ( $ stream -> current ( ) ) { case '{' : $ token = $ this -> lexOpenBracket ( $ stream ) ; break ; case '}' : $ token = $ this -> lexCloseBracket ( $ stream ) ; break ; case '\\' : $ token = $ this -> lexBackslash ( $ stream ) ; break ; case "\t" : $ token = $ this -> lexTab ( $ stream ) ; break ; case "\n" : case "\r" : case "\f" : case "\0" : $ token = $ this -> lexOther ( $ stream ) ; break ; default : $ token = $ this -> lexText ( $ stream ) ; } $ stream -> next ( ) ; } return $ token ; } | Lexes one token from the current stream |
48,943 | public static function createFromStream ( \ Jstewmc \ Stream \ Stream $ stream ) { $ symbol = false ; if ( $ stream -> current ( ) ) { if ( $ stream -> current ( ) === '\\' ) { if ( $ stream -> next ( ) !== false ) { if ( ! ctype_alnum ( $ stream -> current ( ) ) ) { $ symbol = new Symbol ( $ stream -> current ( ) ) ; if ( $ stream -> current ( ) === '\'' ) { $ parameter = $ stream -> next ( ) . $ stream -> next ( ) ; $ symbol -> setParameter ( $ parameter ) ; } if ( $ stream -> next ( ) === ' ' ) { $ symbol -> setIsSpaceDelimited ( true ) ; } else { $ symbol -> setIsSpaceDelimited ( false ) ; $ stream -> previous ( ) ; } } else { throw new \ InvalidArgumentException ( __METHOD__ . "() expects the next element in parameter one, characters, to " . "be a non-alphanumeric character" ) ; } } else { } } else { throw new \ InvalidArgumentException ( __METHOD__ . "() expects the current element in parameter one, characters, to " . "be the backslash character" ) ; } } return $ symbol ; } | Creates a control symbol token from stream |
48,944 | public static function createFromStream ( \ Jstewmc \ Stream \ Stream $ stream ) { $ token = false ; if ( $ stream -> current ( ) ) { if ( $ stream -> current ( ) === '\\' ) { if ( $ stream -> next ( ) !== false ) { if ( ctype_alpha ( $ stream -> current ( ) ) ) { $ word = self :: readWord ( $ stream ) ; if ( ctype_digit ( $ stream -> current ( ) ) || $ stream -> current ( ) == '-' ) { $ parameter = self :: readParameter ( $ stream ) ; } else { $ parameter = null ; } $ token = new Word ( $ word , $ parameter ) ; if ( $ stream -> current ( ) === ' ' ) { $ token -> setIsSpaceDelimited ( true ) ; } else { $ token -> setIsSpaceDelimited ( false ) ; $ stream -> previous ( ) ; } } else { throw new \ InvalidArgumentException ( __METHOD__ . "() expects the next element in parameter one, characters, to " . "be an alphabetic character" ) ; } } else { } } else { throw new \ InvalidArgumentException ( __METHOD__ . "() expects the current element in parameter one, characters, to " . "be the backslash character" ) ; } } return $ token ; } | Creates a control word token from a stream of characters |
48,945 | protected static function readWord ( \ Jstewmc \ Stream \ Stream $ stream ) { $ word = '' ; if ( ctype_alpha ( $ stream -> current ( ) ) ) { while ( ctype_alpha ( $ stream -> current ( ) ) ) { $ word .= $ stream -> current ( ) ; $ stream -> next ( ) ; } } else { throw new \ InvalidArgumentException ( __METHOD__ . "() expects the current element in parameter one, characters, " . "to be an alphabetic character" ) ; } return $ word ; } | Reads a control word s word from the character stream |
48,946 | protected static function readParameter ( \ Jstewmc \ Stream \ Stream $ stream ) { $ parameter = '' ; if ( ctype_digit ( $ stream -> current ( ) ) || $ stream -> current ( ) == '-' ) { $ isNegative = ( $ stream -> current ( ) == '-' ) ; if ( $ isNegative ) { $ stream -> next ( ) ; } while ( ctype_digit ( $ stream -> current ( ) ) ) { $ parameter .= $ stream -> current ( ) ; $ stream -> next ( ) ; } $ parameter = + $ parameter ; if ( $ isNegative ) { $ parameter = - $ parameter ; } } else { throw new \ InvalidArgumentException ( __METHOD__ . "() expects the current element in parameter one, characters, " . "to be a digit or hyphen" ) ; } return $ parameter ; } | Reads a control word s parameter from the characters stream |
48,947 | public function setCharacter ( $ character ) { if ( ! is_string ( $ character ) ) { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter one, character, to be a string" ) ; } $ this -> character = $ character ; return $ this ; } | Sets the token s character |
48,948 | public function setStyle ( \ Jstewmc \ Rtf \ Style $ style = null ) { $ this -> style = $ style ; return $ this ; } | Sets the element s style |
48,949 | public function getIndex ( ) { $ index = false ; if ( ! empty ( $ this -> parent ) ) { $ index = $ this -> parent -> getChildIndex ( $ this ) ; if ( $ index === false ) { throw new \ BadMethodCallException ( __METHOD__ . "() expects this element to be a child of its parent" ) ; } } else { throw new \ BadMethodCallException ( __METHOD__ . "() expects this element to have a parent element" ) ; } return $ index ; } | Returns this element s index in its parent children |
48,950 | public function getNextSibling ( ) { $ next = null ; if ( false !== ( $ index = $ this -> getIndex ( ) ) ) { if ( $ this -> parent -> hasChild ( $ index + 1 ) ) { $ next = $ this -> parent -> getChild ( $ index + 1 ) ; } } return $ next ; } | Returns this element s next sibling or null if no sibling exists |
48,951 | public function getNextText ( ) { $ text = null ; $ next = $ this -> getNextSibling ( ) ; while ( $ next !== null && ! $ next instanceof \ Jstewmc \ Rtf \ Element \ Text ) { $ next = $ next -> getNextSibling ( ) ; } if ( $ next !== null && $ next instanceof \ Jstewmc \ Rtf \ Element \ Text ) { $ text = $ next ; } return $ text ; } | Returns this element s next text element or null if no next text element exists |
48,952 | public function getPreviousSibling ( ) { $ previous = null ; if ( false !== ( $ index = $ this -> getIndex ( ) ) ) { if ( $ this -> parent -> hasChild ( $ index - 1 ) ) { $ previous = $ this -> parent -> getChild ( $ index - 1 ) ; } } return $ previous ; } | Returns this element s previous sibling or null if no sibling exists |
48,953 | public function getPreviousText ( ) { $ text = null ; $ previous = $ this -> getPreviousSibling ( ) ; while ( $ previous !== null && ! $ previous instanceof \ Jstewmc \ Rtf \ Element \ Text ) { $ previous = $ previous -> getPreviousSibling ( ) ; } if ( $ previous !== null && $ previous instanceof \ Jstewmc \ Rtf \ Element \ Text ) { $ text = $ previous ; } return $ text ; } | Returns this element s previous text element or null if not previous text element exists |
48,954 | public function putNextSibling ( Element $ element ) { if ( false !== ( $ index = $ this -> getIndex ( ) ) ) { $ this -> parent -> insertChild ( $ element , $ index + 1 ) ; } return $ this ; } | Inserts an element after this element |
48,955 | public function toRtf ( ) { $ text = str_replace ( '\\' , '\\\\' , $ this -> text ) ; $ text = str_replace ( '{' , '\{' , $ text ) ; $ text = str_replace ( '}' , '\}' , $ text ) ; return "$text" ; } | Returns this text as an rtf string |
48,956 | protected function toRtf ( ) { $ rtf = '' ; if ( $ this -> word ) { if ( $ this -> isIgnored ) { $ rtf = '\\*' ; } $ rtf .= "\\{$this->word}{$this->parameter}" ; if ( $ this -> isSpaceDelimited ) { $ rtf .= ' ' ; } } return $ rtf ; } | Returns this control word as an rtf string |
48,957 | private function retrieveFieldDescription ( AdminInterface $ admin , $ field ) { $ admin -> getFormFieldDescriptions ( ) ; $ fieldDescription = $ admin -> getFormFieldDescription ( $ field ) ; if ( ! $ fieldDescription ) { throw new \ RuntimeException ( sprintf ( 'The field "%s" does not exist.' , $ field ) ) ; } if ( 'sonata_type_model_autocomplete' !== $ fieldDescription -> getType ( ) ) { throw new \ RuntimeException ( sprintf ( 'Unsupported form type "%s" for field "%s".' , $ fieldDescription -> getType ( ) , $ field ) ) ; } return $ fieldDescription ; } | Retrieve the field description given by field name . |
48,958 | public function build ( AdminInterface $ admin , RouteCollection $ collection ) { $ collection -> add ( 'list' ) ; $ collection -> add ( 'create' ) ; $ collection -> add ( 'batch' , null , [ ] , [ ] , [ ] , '' , [ ] , [ 'POST' ] ) ; $ collection -> add ( 'edit' , $ admin -> getRouterIdParameter ( ) . '/edit' , [ ] , [ 'id' => '.+' ] ) ; $ collection -> add ( 'delete' , $ admin -> getRouterIdParameter ( ) . '/delete' , [ ] , [ 'id' => '.+' ] ) ; $ collection -> add ( 'export' ) ; $ collection -> add ( 'show' , $ admin -> getRouterIdParameter ( ) . '/show' , [ ] , [ 'id' => '.+' ] , [ ] , '' , [ ] , [ 'GET' ] ) ; if ( $ admin -> isAclEnabled ( ) ) { $ collection -> add ( 'acl' , $ admin -> getRouterIdParameter ( ) . '/acl' , [ ] , [ 'id' => '.+' ] ) ; } foreach ( $ admin -> getChildren ( ) as $ children ) { $ collection -> addCollection ( $ children -> getRoutes ( ) ) ; } } | RouteBuilder that allows slashes in the ids . |
48,959 | private function loadDocumentTree ( $ config , ContainerBuilder $ container ) { $ configuration = [ 'routing_defaults' => $ config [ 'routing_defaults' ] , 'repository_name' => $ config [ 'repository_name' ] , 'sortable_by' => $ config [ 'sortable_by' ] , 'move' => true , 'reorder' => true , ] ; $ container -> setParameter ( 'sonata_admin_doctrine_phpcr.tree_block.configuration' , $ configuration ) ; foreach ( $ configuration as $ key => $ value ) { $ container -> setParameter ( 'sonata_admin_doctrine_phpcr.tree_block.' . $ key , $ value ) ; } } | Set the document tree parameters and configuration . |
48,960 | public function fixFieldDescription ( AdminInterface $ admin , FieldDescriptionInterface $ fieldDescription ) { $ fieldDescription -> setAdmin ( $ admin ) ; $ metadata = null ; if ( $ admin -> getModelManager ( ) -> hasMetadata ( $ admin -> getClass ( ) ) ) { $ metadata = $ admin -> getModelManager ( ) -> getMetadata ( $ admin -> getClass ( ) ) ; if ( isset ( $ metadata -> mappings [ $ fieldDescription -> getName ( ) ] ) ) { $ fieldDescription -> setFieldMapping ( $ metadata -> mappings [ $ fieldDescription -> getName ( ) ] ) ; } if ( $ metadata -> hasAssociation ( $ fieldDescription -> getName ( ) ) ) { $ fieldDescription -> setAssociationMapping ( $ metadata -> getAssociation ( $ fieldDescription -> getName ( ) ) ) ; } } if ( ! $ fieldDescription -> getType ( ) ) { throw new \ RuntimeException ( sprintf ( 'Please define a type for field `%s` in `%s`' , $ fieldDescription -> getName ( ) , \ get_class ( $ admin ) ) ) ; } $ fieldDescription -> setOption ( 'code' , $ fieldDescription -> getOption ( 'code' , $ fieldDescription -> getName ( ) ) ) ; $ fieldDescription -> setOption ( 'label' , $ fieldDescription -> getOption ( 'label' , $ fieldDescription -> getName ( ) ) ) ; if ( ! $ fieldDescription -> getTemplate ( ) ) { $ fieldDescription -> setTemplate ( $ this -> getTemplate ( $ fieldDescription -> getType ( ) ) ) ; if ( ClassMetadata :: MANY_TO_ONE == $ fieldDescription -> getMappingType ( ) ) { $ fieldDescription -> setTemplate ( '@SonataAdmin/CRUD/Association/show_many_to_one.html.twig' ) ; } if ( ClassMetadata :: MANY_TO_MANY == $ fieldDescription -> getMappingType ( ) ) { $ fieldDescription -> setTemplate ( '@SonataAdmin/CRUD/Association/show_many_to_many.html.twig' ) ; } } $ mappingTypes = [ ClassMetadata :: MANY_TO_ONE , ClassMetadata :: MANY_TO_MANY , 'children' , 'child' , 'parent' , 'referrers' , ] ; if ( $ metadata && $ metadata -> hasAssociation ( $ fieldDescription -> getName ( ) ) && \ in_array ( $ fieldDescription -> getMappingType ( ) , $ mappingTypes , true ) ) { $ admin -> attachAdminClass ( $ fieldDescription ) ; } } | The method defines the correct default settings for the provided FieldDescription . |
48,961 | public function init ( ) { if ( ! $ this -> getQuery ( ) ) { throw new \ RuntimeException ( 'Uninitialized QueryBuilder' ) ; } $ this -> resetIterator ( ) ; $ this -> setNbResults ( $ this -> computeNbResult ( ) ) ; if ( 0 == $ this -> getPage ( ) || 0 == $ this -> getMaxPerPage ( ) || 0 == $ this -> getNbResults ( ) ) { $ this -> setLastPage ( 0 ) ; $ this -> getQuery ( ) -> setFirstResult ( 0 ) ; $ this -> getQuery ( ) -> setMaxResults ( 0 ) ; } else { $ offset = ( $ this -> getPage ( ) - 1 ) * $ this -> getMaxPerPage ( ) ; $ this -> setLastPage ( ceil ( $ this -> getNbResults ( ) / $ this -> getMaxPerPage ( ) ) ) ; $ this -> getQuery ( ) -> setFirstResult ( $ offset ) ; $ this -> getQuery ( ) -> setMaxResults ( $ this -> getMaxPerPage ( ) ) ; } } | Initializes the pager setting the offset and maxResults in ProxyQuery and obtaining the total number of pages . |
48,962 | public function find ( $ class , $ id ) { if ( ! isset ( $ id ) ) { return ; } if ( null === $ class ) { return $ this -> dm -> find ( null , $ id ) ; } return $ this -> dm -> getRepository ( $ class ) -> find ( $ id ) ; } | Find one object from the given class repository . |
48,963 | public function getIdentifierValues ( $ document ) { $ class = $ this -> getMetadata ( ClassUtils :: getClass ( $ document ) ) ; $ path = $ class -> reflFields [ $ class -> identifier ] -> getValue ( $ document ) ; return [ $ path ] ; } | Transforms the document into the PHPCR path . |
48,964 | public function getNormalizedIdentifier ( $ document ) { if ( is_scalar ( $ document ) ) { throw new \ InvalidArgumentException ( 'Invalid argument, object or null required' ) ; } if ( ! $ document || ! $ this -> getDocumentManager ( ) -> contains ( $ document ) ) { return ; } $ values = $ this -> getIdentifierValues ( $ document ) ; return $ values [ 0 ] ; } | This is just taking the id out of the array again . |
48,965 | public function getSubject ( ) { if ( null === $ this -> subject && $ this -> request ) { $ id = $ this -> request -> get ( $ this -> getIdParameter ( ) ) ; if ( null === $ id || ! preg_match ( '#^[0-9A-Za-z/\-_]+$#' , $ id ) ) { $ this -> subject = false ; } else { if ( ! UUIDHelper :: isUUID ( $ id ) ) { $ id = PathHelper :: absolutizePath ( $ id , '/' ) ; } $ this -> subject = $ this -> getObject ( $ id ) ; } } return $ this -> subject ; } | Get subject . |
48,966 | public function setSortOrder ( $ sortOrder ) { if ( ! \ in_array ( $ sortOrder , [ 'ASC' , 'DESC' ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The parameter $sortOrder must be one of "ASC" or "DESC", got "%s"' , $ sortOrder ) ) ; } $ this -> sortOrder = $ sortOrder ; return $ this ; } | Set the sort ordering . |
48,967 | protected function getWhere ( ProxyQuery $ proxy ) { $ queryBuilder = $ proxy -> getQueryBuilder ( ) ; if ( self :: CONDITION_OR == $ this -> getCondition ( ) ) { return $ queryBuilder -> orWhere ( ) ; } return $ queryBuilder -> andWhere ( ) ; } | Add the where statement for this filter to the query . |
48,968 | public function preRender ( $ pugCode ) { $ parts = $ this -> getPugCodeLayoutStructure ( $ pugCode ) ; $ className = get_class ( $ this ) ; foreach ( $ this -> replacements as $ name => $ callable ) { $ parts [ 0 ] .= ":php\n" . " if (!function_exists('$name')) {\n" . " function $name() {\n" . " return call_user_func_array($className::getGlobalHelper('$name'), func_get_args());\n" . " }\n" . " }\n" ; } return implode ( '' , $ parts ) ; } | Pug code transformation to do before Pug render . |
48,969 | public function getParameters ( array $ parameters = [ ] ) { foreach ( [ 'view' , 'this' ] as $ forbiddenKey ) { if ( array_key_exists ( $ forbiddenKey , $ parameters ) ) { throw new \ ErrorException ( 'The "' . $ forbiddenKey . '" key is forbidden.' ) ; } } $ sharedVariables = $ this -> getOptionDefault ( 'shared_variables' ) ; if ( $ sharedVariables ) { $ parameters = array_merge ( $ sharedVariables , $ parameters ) ; } $ parameters [ 'view' ] = $ this ; return $ parameters ; } | Prepare and group input and global parameters . |
48,970 | public function render ( $ name , array $ parameters = [ ] ) { $ parameters = $ this -> getParameters ( $ parameters ) ; $ method = method_exists ( $ this -> jade , 'renderFile' ) ? [ $ this -> jade , 'renderFile' ] : [ $ this -> jade , 'render' ] ; return call_user_func ( $ method , $ this -> getFileFromName ( $ name ) , $ parameters ) ; } | Render a template by name . |
48,971 | public function renderString ( $ code , array $ parameters = [ ] ) { $ parameters = $ this -> getParameters ( $ parameters ) ; $ method = method_exists ( $ this -> jade , 'renderString' ) ? [ $ this -> jade , 'renderString' ] : [ $ this -> jade , 'render' ] ; return call_user_func ( $ method , $ code , $ parameters ) ; } | Render a template string . |
48,972 | public function supports ( $ name ) { $ extensions = method_exists ( $ this -> jade , 'getExtensions' ) ? $ this -> jade -> getExtensions ( ) : $ this -> jade -> getOption ( 'extensions' ) ; foreach ( $ extensions as $ extension ) { if ( substr ( $ name , - strlen ( $ extension ) ) === $ extension ) { return true ; } } return false ; } | Check if a file extension is supported by Pug . |
48,973 | protected function findTemplate ( $ name , $ throw = null ) { $ result = parent :: findTemplate ( $ name , false ) ; if ( $ result === false ) { return __DIR__ . '/../Test/Fixtures/twig/empty.twig' ; } return $ result ; } | Hacked find template to allow loading templates by absolute path . |
48,974 | protected function newGenerator ( $ type , $ length = null ) { $ generator = GeneratorFactory :: create ( $ type ) -> mutate ( $ this ) -> length ( $ length ? : $ this -> length ) ; if ( isset ( $ this -> prefix ) ) { $ generator -> prefix ( $ this -> prefix ) ; } if ( isset ( $ this -> suffix ) ) { $ generator -> suffix ( $ this -> suffix ) ; } return $ generator ; } | Creates a new generator instance of the given type . |
48,975 | protected function newGeneratorFromAlias ( $ alias , $ length = null ) { $ generatorAliases = [ 'numeric' => 'numeric' , 'alphanum' => 'alphaNumeric' , 'token' => 'token' , 'bytes' => 'randomByte' ] ; if ( array_key_exists ( $ alias , $ generatorAliases ) ) { return $ this -> newGenerator ( $ generatorAliases [ $ alias ] , $ length ) ; } } | Creates a new generator instance from the given alias . |
48,976 | private static function objectDiffInArrays ( $ array1 , $ array2 ) { return array_udiff ( $ array1 , $ array2 , function ( $ a , $ b ) { if ( $ a === $ b ) { return 0 ; } elseif ( $ a < $ b ) { return - 1 ; } elseif ( $ a > $ b ) { return 1 ; } } ) ; } | Object difference comparator using array_diff callback . |
48,977 | public function mutate ( $ objects ) { $ objects = call_user_func_array ( array ( $ this , 'flattenArguments' ) , func_get_args ( ) ) ; $ collect = [ ] ; foreach ( $ objects as $ obj ) { if ( $ obj instanceof AbstractGenerator ) { array_push ( $ collect , $ obj ) ; continue ; } throw new InvalidArgumentException ( sprintf ( 'Mutable objects must be instances of %s.' , AbstractGenerator :: class ) ) ; } $ this -> mutates = array_merge ( static :: objectDiffInArrays ( $ this -> mutates , $ collect ) , $ collect ) ; return $ this ; } | Add mutable generators to the mutates collection |
48,978 | public function dontMutate ( $ objects ) { $ objects = call_user_func_array ( array ( $ this , 'flattenArguments' ) , func_get_args ( ) ) ; $ this -> mutates = static :: objectDiffInArrays ( $ this -> mutates , $ objects ) ; return $ this ; } | Remove generators from the mutates collection |
48,979 | public static function create ( $ type ) { $ generator = sprintf ( "Keygen\Generators\%sGenerator" , ucfirst ( $ type ) ) ; if ( class_exists ( $ generator ) ) { $ generator = new $ generator ; if ( $ generator instanceof Generator ) { return $ generator ; } } throw new InvalidArgumentException ( 'Cannot create unknown generator type.' ) ; } | Create a generator instance from the specified type . |
48,980 | protected function flattenArguments ( ) { $ args = func_get_args ( ) ; $ flat = [ ] ; foreach ( $ args as $ arg ) { if ( is_array ( $ arg ) ) { $ flat = call_user_func_array ( array ( $ this , 'flattenArguments' ) , array_merge ( $ flat , $ arg ) ) ; continue ; } array_push ( $ flat , $ arg ) ; } return $ flat ; } | Flattens its arguments array into a simple array . |
48,981 | public function mutable ( $ props ) { $ props = call_user_func_array ( array ( $ this , 'flattenArguments' ) , func_get_args ( ) ) ; $ collect = $ unknown = [ ] ; foreach ( $ props as $ prop ) { if ( ! property_exists ( AbstractGenerator :: class , $ prop ) ) { array_push ( $ unknown , $ prop ) ; continue ; } array_push ( $ collect , $ prop ) ; } if ( ! empty ( $ unknown ) ) { throw new InvalidArgumentException ( sprintf ( "Cannot add unknown %s to mutables collection ('%s')." , ( count ( $ unknown ) > 1 ) ? 'properties' : 'property' , join ( "', '" , $ unknown ) ) ) ; } $ this -> mutables = array_merge ( array_diff ( $ this -> mutables , $ collect ) , $ collect ) ; return $ this ; } | Add mutable attributes to the mutables collection |
48,982 | public function immutable ( $ props ) { $ props = call_user_func_array ( array ( $ this , 'flattenArguments' ) , func_get_args ( ) ) ; $ this -> mutables = array_diff ( $ this -> mutables , $ props ) ; return $ this ; } | Remove attributes from the mutables collection |
48,983 | protected function propagateMutation ( $ prop , $ propagate ) { $ propagate = ! is_bool ( $ propagate ) ? true : $ propagate ; if ( $ propagate && isset ( $ this -> mutates ) ) { foreach ( $ this -> mutates as $ obj ) { if ( in_array ( $ prop , $ obj -> mutables ) ) { call_user_func ( array ( $ obj , $ prop ) , $ this -> { $ prop } ) ; } } } return $ this ; } | Propagates property mutation to listed mutable generators . |
48,984 | protected function length ( $ length , $ propagate = true ) { $ this -> length = $ this -> intCast ( $ length ? : $ this -> length ) ; return $ this -> propagateMutation ( 'length' , $ propagate ) ; } | Sets the length of keys to be generated by the generator . |
48,985 | protected function affix ( $ affix , $ value , $ propagate = true ) { $ affixes = [ 'prefix' , 'suffix' ] ; if ( in_array ( $ affix , $ affixes ) ) { if ( is_scalar ( $ value ) ) { $ this -> { $ affix } = strval ( $ value ) ; return $ this -> propagateMutation ( $ affix , $ propagate ) ; } throw new InvalidArgumentException ( "The given {$affix} cannot be converted to a string." ) ; } } | Affixes string to generated keys . |
48,986 | protected function getAdjustedKeyLength ( ) { return $ this -> length - intval ( strlen ( $ this -> prefix ) + strlen ( $ this -> suffix ) ) ; } | Gets the key length less the prefix length and suffix length . |
48,987 | protected function __overloadMethods ( $ method , $ args ) { $ _method = strtolower ( $ method ) ; if ( in_array ( $ _method , [ 'prefix' , 'suffix' ] ) ) { return call_user_func_array ( array ( $ this , 'affix' ) , array_merge ( [ $ _method ] , $ args ) ) ; } if ( $ _method == 'length' ) { return call_user_func_array ( array ( $ this , 'length' ) , $ args ) ; } throw new BadMethodCallException ( sprintf ( "Call to unknown method %s::%s()" , get_called_class ( ) , $ method ) ) ; } | Overload helper for internal method calls . |
48,988 | protected function setUrl ( $ params ) { curl_setopt ( $ this -> client -> ch , CURLOPT_URL , Constants :: API_URL . trim ( $ params , '/' ) ) ; } | setUrl function . |
48,989 | protected function execute ( $ request_type , $ form = array ( ) ) { curl_setopt ( $ this -> client -> ch , CURLOPT_CUSTOMREQUEST , $ request_type ) ; if ( is_array ( $ form ) && ! empty ( $ form ) ) { curl_setopt ( $ this -> client -> ch , CURLOPT_POSTFIELDS , $ this -> httpBuildQuery ( $ form , '' , '&' ) ) ; } $ fh_header = fopen ( 'php://temp' , 'w+' ) ; curl_setopt ( $ this -> client -> ch , CURLOPT_WRITEHEADER , $ fh_header ) ; curl_setopt ( $ this -> client -> ch , CURLINFO_HEADER_OUT , true ) ; $ response_data = curl_exec ( $ this -> client -> ch ) ; if ( curl_errno ( $ this -> client -> ch ) !== 0 ) { fclose ( $ fh_header ) ; throw new Exception ( curl_error ( $ this -> client -> ch ) , curl_errno ( $ this -> client -> ch ) ) ; } $ sent_headers = curl_getinfo ( $ this -> client -> ch , CURLINFO_HEADER_OUT ) ; rewind ( $ fh_header ) ; $ received_headers = stream_get_contents ( $ fh_header ) ; fclose ( $ fh_header ) ; $ response_code = ( int ) curl_getinfo ( $ this -> client -> ch , CURLINFO_HTTP_CODE ) ; return new Response ( $ response_code , $ sent_headers , $ received_headers , $ response_data ) ; } | EXECUTE function . |
48,990 | public function getClass ( $ class ) { $ this -> checkClass ( $ class ) ; if ( null === $ this -> infoClass ) { $ infoClass = get_class ( $ this ) . 'Info' ; $ this -> infoClass = new $ infoClass ( ) ; } return $ this -> infoClass -> { 'get' . str_replace ( '\\' , '' , $ class ) . 'Class' } ( ) ; } | Returns the metadata of a class . |
48,991 | public function renderToImage ( \ NMC \ ImageWithText \ Image $ image ) { $ this -> distributeText ( ) ; $ maxWidthString = implode ( '' , array_fill ( 0 , $ this -> width , 'x' ) ) ; $ maxWidthBoundingBox = imagettfbbox ( $ this -> size , 0 , $ this -> font , $ maxWidthString ) ; $ maxLineWidth = abs ( $ maxWidthBoundingBox [ 0 ] - $ maxWidthBoundingBox [ 2 ] ) ; for ( $ j = 0 ; $ j < count ( $ this -> lines ) ; $ j ++ ) { $ line = & $ this -> lines [ $ j ] ; if ( empty ( $ line [ 'words' ] ) ) { unset ( $ this -> lines [ $ j ] ) ; continue ; } $ lineText = implode ( ' ' , $ line [ 'words' ] ) ; $ lineBoundingBox = imagettfbbox ( $ this -> size , 0 , $ this -> font , $ lineText ) ; $ line [ 'width' ] = abs ( $ lineBoundingBox [ 0 ] - $ lineBoundingBox [ 2 ] ) ; $ line [ 'text' ] = $ lineText ; } for ( $ i = 0 ; $ i < count ( $ this -> lines ) ; $ i ++ ) { if ( array_key_exists ( $ i , $ this -> lines ) ) { $ line = & $ this -> lines [ $ i ] ; $ lineBoundingBox = imagettfbbox ( $ this -> size , 0 , $ this -> font , $ line [ 'text' ] ) ; $ lineWidth = abs ( $ lineBoundingBox [ 0 ] - $ lineBoundingBox [ 2 ] ) ; switch ( $ this -> align ) { case 'left' : $ offsetX = $ this -> startX ; $ offsetY = $ this -> startY + $ this -> lineHeight + ( $ this -> lineHeight * $ i ) ; break ; case 'center' : $ imageWidth = $ image -> getWidth ( ) ; $ offsetX = ( ( $ maxLineWidth - $ lineWidth ) / 2 ) + $ this -> startX ; $ offsetY = $ this -> startY + $ this -> lineHeight + ( $ this -> lineHeight * $ i ) ; break ; case 'right' : $ imageWidth = $ image -> getWidth ( ) ; $ offsetX = $ imageWidth - $ line [ 'width' ] - $ this -> startX ; $ offsetY = $ this -> startY + $ this -> lineHeight + ( $ this -> lineHeight * $ i ) ; break ; } $ image -> getImage ( ) -> text ( $ line [ 'text' ] , $ offsetX , $ offsetY , $ this -> size , $ this -> color , 0 , $ this -> font ) ; } } } | Render text on image |
48,992 | protected function distributeText ( ) { $ words = explode ( ' ' , $ this -> text ) ; while ( $ words ) { $ tooLong = true ; $ word = array_shift ( $ words ) ; for ( $ i = 0 ; $ i < count ( $ this -> lines ) ; $ i ++ ) { $ line = & $ this -> lines [ $ i ] ; if ( $ line [ 'full' ] === false ) { $ charsPotential = strlen ( $ word ) + $ line [ 'chars' ] ; if ( $ charsPotential <= $ this -> width ) { array_push ( $ line [ 'words' ] , $ word ) ; $ line [ 'chars' ] = $ charsPotential ; $ tooLong = false ; break ; } else { $ line [ 'full' ] = true ; } } } } if ( $ tooLong === true ) { throw new \ Exception ( 'Text is too long' ) ; } } | Distribute text to lines |
48,993 | public function refresh ( ) { if ( $ this -> isNew ( ) ) { throw new \ LogicException ( 'The document is new.' ) ; } $ this -> setDocumentData ( $ this -> getRepository ( ) -> getCollection ( ) -> findOne ( array ( '_id' => $ this -> getId ( ) ) ) , true ) ; return $ this ; } | Refresh the document data from the database . |
48,994 | public function isModified ( ) { if ( isset ( $ this -> data [ 'fields' ] ) ) { foreach ( $ this -> data [ 'fields' ] as $ name => $ value ) { if ( $ this -> isFieldModified ( $ name ) ) { return true ; } } } if ( isset ( $ this -> data [ 'embeddedsOne' ] ) ) { foreach ( $ this -> data [ 'embeddedsOne' ] as $ name => $ embedded ) { if ( $ embedded && $ embedded -> isModified ( ) ) { return true ; } if ( $ this -> isEmbeddedOneChanged ( $ name ) ) { $ root = null ; if ( $ this instanceof Document ) { $ root = $ this ; } elseif ( $ rap = $ this -> getRootAndPath ( ) ) { $ root = $ rap [ 'root' ] ; } if ( $ root && ! $ root -> isNew ( ) ) { return true ; } } } } if ( isset ( $ this -> data [ 'embeddedsMany' ] ) ) { foreach ( $ this -> data [ 'embeddedsMany' ] as $ name => $ group ) { foreach ( $ group -> getAdd ( ) as $ document ) { if ( $ document -> isModified ( ) ) { return true ; } } $ root = null ; if ( $ this instanceof Document ) { $ root = $ this ; } elseif ( $ rap = $ this -> getRootAndPath ( ) ) { $ root = $ rap [ 'root' ] ; } if ( $ root && ! $ root -> isNew ( ) ) { if ( $ group -> getRemove ( ) ) { return true ; } } if ( $ group -> isSavedInitialized ( ) ) { foreach ( $ group -> getSaved ( ) as $ document ) { if ( $ document -> isModified ( ) ) { return true ; } } } } } return false ; } | Returns if the document is modified . |
48,995 | public function isFieldModified ( $ name ) { return isset ( $ this -> fieldsModified [ $ name ] ) || array_key_exists ( $ name , $ this -> fieldsModified ) ; } | Returns if a field is modified . |
48,996 | public function getOriginalFieldValue ( $ name ) { if ( $ this -> isFieldModified ( $ name ) ) { return $ this -> fieldsModified [ $ name ] ; } if ( isset ( $ this -> data [ 'fields' ] [ $ name ] ) ) { return $ this -> data [ 'fields' ] [ $ name ] ; } return null ; } | Returns the original value of a field . |
48,997 | public function isEmbeddedOneChanged ( $ name ) { if ( ! isset ( $ this -> data [ 'embeddedsOne' ] ) ) { return false ; } if ( ! isset ( $ this -> data [ 'embeddedsOne' ] [ $ name ] ) && ! array_key_exists ( $ name , $ this -> data [ 'embeddedsOne' ] ) ) { return false ; } return Archive :: has ( $ this , 'embedded_one.' . $ name ) ; } | Returns if an embedded one is changed . |
48,998 | public function getOriginalEmbeddedOneValue ( $ name ) { if ( Archive :: has ( $ this , 'embedded_one.' . $ name ) ) { return Archive :: get ( $ this , 'embedded_one.' . $ name ) ; } if ( isset ( $ this -> data [ 'embeddedsOne' ] [ $ name ] ) ) { return $ this -> data [ 'embeddedsOne' ] [ $ name ] ; } return null ; } | Returns the original value of an embedded one . |
48,999 | public function getEmbeddedsOneChanged ( ) { $ embeddedsOneChanged = array ( ) ; if ( isset ( $ this -> data [ 'embeddedsOne' ] ) ) { foreach ( $ this -> data [ 'embeddedsOne' ] as $ name => $ embedded ) { if ( $ this -> isEmbeddedOneChanged ( $ name ) ) { $ embeddedsOneChanged [ $ name ] = $ this -> getOriginalEmbeddedOneValue ( $ name ) ; } } } return $ embeddedsOneChanged ; } | Returns an array with the embedded ones changed with the embedded name as key and the original embedded value as value . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.