idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
8,700 | public function insertBatch ( array $ row ) { $ this -> batch [ ] = $ row ; if ( count ( $ this -> batch ) >= $ this -> batch_size ) { $ this -> flushBatch ( ) ; return true ; } return false ; } | Insert a row into batch . |
8,701 | public function flushBatch ( ) { if ( count ( $ this -> batch ) > 0 ) { $ this -> insertMany ( $ this -> batch , $ this -> batch_replace ) ; $ this -> batch = [ ] ; return true ; } return false ; } | Flush the batch . |
8,702 | public function reverse ( ) { if ( ! $ this -> orderBy ) throw new \ Exception ( 'Cannot reverse a query without order by.' ) ; preg_match_all ( '/([^,])*([(].*?[)])([^,])*|([^,])+/' , $ this -> orderBy , $ e ) ; $ e = $ e [ 0 ] ; foreach ( $ e as $ k => $ v ) { $ v = preg_replace_callback ( '/(DESC|ASC)[\s]*/' , funct... | Reverse the query order . |
8,703 | public function from ( $ tables , $ alias = null ) { $ this -> tables = [ ] ; if ( is_string ( $ tables ) ) return $ this -> addFrom ( $ tables ) ; else return $ this -> addFrom ( [ $ alias => $ tables ] ) ; } | Set FROM tables . |
8,704 | public function addFrom ( $ tables ) { if ( ! $ tables ) return $ this ; if ( is_string ( $ tables ) ) $ tables = explode ( ',' , $ tables ) ; elseif ( ! is_array ( $ tables ) ) $ tables = [ $ tables ] ; foreach ( $ tables as $ k => $ tablestr ) { if ( $ tablestr instanceof static ) { $ table = $ tablestr ; $ alias = $... | Add FROM tables . |
8,705 | public function removeFrom ( $ what ) { foreach ( $ this -> tables as $ alias => $ table ) { if ( $ alias === $ what ) { unset ( $ this -> tables [ $ alias ] ) ; break ; } } return $ this ; } | Remove a FROM table . |
8,706 | public function join ( $ type , $ table , $ conditions = null , $ recursive = true ) { if ( $ recursive && is_array ( $ table ) ) { foreach ( $ table as $ _table => $ _conditions ) { if ( $ _conditions instanceof static ) $ this -> join ( $ type , $ table , $ conditions , false ) ; elseif ( $ _conditions instanceof Raw... | Create a jointure . |
8,707 | public function next ( ) { if ( $ this -> query === null ) $ this -> query ( ) ; return $ this -> current = $ this -> query -> next ( ) ; } | Return the next row . |
8,708 | public function reset ( ) { $ this -> tables = [ ] ; $ this -> columns = [ ] ; $ this -> where = [ ] ; $ this -> offset = null ; $ this -> limit = null ; $ this -> orderBy = [ ] ; $ this -> groupBy = [ ] ; $ this -> joins = [ ] ; $ this -> params = [ ] ; return $ this ; } | Reset all parameters . |
8,709 | public function paginate ( $ page , $ per_page = 10 ) { $ this -> page = $ page = $ page ? $ page : 1 ; $ this -> per_page = $ per_page ; $ this -> offset ( ( $ page - 1 ) * $ per_page ) ; $ this -> limit ( $ per_page ) ; return $ this ; } | Paginate the results . |
8,710 | public function addSelect ( $ columns ) { if ( is_array ( $ columns ) ) return $ this -> _addSelect ( $ columns ) ; $ columns = explode ( ',' , $ columns ) ; foreach ( $ columns as $ columnstr ) { $ columnstr = trim ( $ columnstr ) ; preg_match ( '/(.*?)\s+as\s+([a-z_][a-zA-Z0-9_]*)?$/i' , $ columnstr , $ matches ) ; i... | Add SELECT columns . |
8,711 | protected function _addSelect ( array $ columns ) { if ( array_values ( $ columns ) === $ columns ) { foreach ( $ columns as $ k => $ v ) { unset ( $ columns [ $ k ] ) ; $ columns [ $ v ] = $ v ; } } $ this -> columns = array_merge ( $ this -> columns , $ columns ) ; return $ this ; } | Add array of SELECT columns . |
8,712 | public function removeSelect ( $ what ) { foreach ( $ this -> columns as $ alias => $ column ) { if ( $ alias === $ what ) { unset ( $ this -> columns [ $ alias ] ) ; break ; } } return $ this ; } | Remove a SELECT column . |
8,713 | public function where ( $ conditions , $ values = null ) { if ( ! $ conditions ) return $ this ; if ( $ values !== null ) $ this -> where [ ] = [ $ conditions => $ values ] ; else $ this -> where [ ] = $ conditions ; return $ this ; } | Add WHERE conditions . |
8,714 | protected function replace ( $ condition , $ setTable = true ) { $ condition = preg_replace_callback ( '/(?<![\.a-zA-Z0-9_' . $ this -> quote . '\(\)])[a-z_][a-zA-Z0-9._]*(?![^\(]*\))/' , function ( $ matches ) use ( $ setTable ) { if ( $ setTable && strpos ( $ matches [ 0 ] , '.' ) === false && count ( $ this -> joins... | Format identifiers . |
8,715 | protected function identifierQuotes ( $ str ) { return preg_replace_callback ( '/(?<![\.a-zA-Z0-9_' . $ this -> quote . '\(\)])[a-z_][a-zA-Z0-9._]*/' , function ( $ matches ) { $ res = [ ] ; foreach ( explode ( '.' , $ matches [ 0 ] ) as $ substr ) { if ( preg_match ( '/^[a-z_][a-zA-Z0-9_]*$/' , $ substr ) ) $ res [ ] ... | Quote idenfitiers . |
8,716 | protected function buildColumns ( ) { $ select = [ ] ; $ params = [ ] ; if ( ! $ this -> columns ) return [ '*' , [ ] ] ; else { foreach ( $ this -> columns as $ alias => $ column ) { if ( $ column instanceof static ) { $ sql = $ column -> buildSQL ( ) ; $ params = array_merge ( $ params , $ column -> getParameters ( )... | Build the list of columns . |
8,717 | protected function getDefaultTable ( $ real = false ) { if ( count ( $ this -> tables ) === 1 ) { if ( $ real ) return array_values ( $ this -> tables ) [ 0 ] ; else return array_keys ( $ this -> tables ) [ 0 ] ; } else return null ; } | Return the default table . |
8,718 | protected function buildWhere ( $ default = null ) { $ r = $ this -> processConditions ( $ this -> where , 'and' , false , $ default !== null ? $ default : $ this -> getDefaultTable ( ) ) ; if ( $ r [ 0 ] ) return [ "\n" . 'WHERE ' . $ r [ 0 ] , $ r [ 1 ] ] ; else return [ '' , [ ] ] ; } | Build the WHERE conditions . |
8,719 | protected function buildGroupBy ( ) { if ( ! $ this -> groupBy || ! $ this -> groupBy [ 0 ] ) return [ '' , [ ] ] ; $ groupBy = $ this -> groupBy ; $ groupBySql = $ groupBy [ 0 ] ; $ groupByParameters = $ groupBy [ 1 ] ; $ res = [ ] ; foreach ( explode ( ',' , $ groupBySql ) as $ column ) { if ( $ this -> isIdentifier ... | Build GROUP BY . |
8,720 | protected function buildOrderby ( ) { if ( ! $ this -> orderBy || ! $ this -> orderBy [ 0 ] ) return [ '' , [ ] ] ; $ res = [ ] ; $ orderBy = $ this -> orderBy ; $ orderBySql = $ orderBy [ 0 ] ; $ orderByParameters = $ orderBy [ 1 ] ; foreach ( explode ( ',' , $ orderBySql ) as $ orderbystr ) { $ orderbystr = trim ( $ ... | Build ORDER By . |
8,721 | protected function buildJointures ( ) { $ params = [ ] ; $ jointures = '' ; foreach ( $ this -> joins as $ alias => $ jointure ) { $ type = $ jointure [ 0 ] ; $ table = $ jointure [ 1 ] ; $ conditions = $ jointure [ 2 ] ; $ alias = $ alias !== $ table ? $ alias : null ; $ res = $ this -> buildJointure ( $ type , $ tabl... | Build jointures . |
8,722 | protected function buildJointure ( $ type , $ table , $ conditions , $ alias = null ) { $ params = [ ] ; $ jointure = '' ; switch ( $ type ) { case 'leftjoin' : $ jointure = "\n" . 'LEFT JOIN ' ; break ; case 'rightjoin' : $ jointure = "\n" . 'RIGHT JOIN ' ; break ; case 'innerjoin' : $ jointure = "\n" . 'INNER JOIN ' ... | Build a jointure . |
8,723 | protected function buildTables ( $ with_alias = true ) { $ tables = [ ] ; $ params = [ ] ; if ( ! $ this -> tables ) throw new \ Exception ( 'Must set tables with method from($tables) before running the query.' ) ; foreach ( $ this -> tables as $ alias => $ table ) { if ( $ table instanceof static ) { $ tables [ ] = '(... | Build the lit of tables . |
8,724 | protected function replaceRaws ( & $ sql , & $ params ) { $ i = 0 ; $ sql = preg_replace_callback ( '/\?/' , function ( ) use ( & $ i , & $ params ) { if ( $ params [ $ i ] instanceof static ) { $ r = $ params [ $ i ] ; $ sql = $ r -> buildSQL ( ) ; $ params = array_merge ( array_slice ( $ params , 0 , $ i ) , $ r -> g... | Replace ? with raw queries . |
8,725 | public function buildSQL ( $ union = false ) { $ params = [ ] ; list ( $ tables , $ tableparams ) = $ this -> buildTables ( ) ; $ params = array_merge ( $ params , $ tableparams ) ; list ( $ columns , $ columnsparams ) = $ this -> buildColumns ( ) ; $ params = array_merge ( $ params , $ columnsparams ) ; list ( $ joint... | Build a SELECT SQL query . |
8,726 | public function replaceTableInConditions ( $ conditions , $ oldTable , $ newTable ) { foreach ( $ conditions as $ k => $ v ) { if ( is_array ( $ v ) ) $ v = $ this -> replaceTableInConditions ( $ v , $ oldTable , $ newTable ) ; else $ v = preg_replace ( '/(?<![a-zA-Z0-9_])' . $ oldTable . '\./' , $ newTable . '.' , $ v... | Replace an alias in conditions . |
8,727 | public function replaceTable ( $ oldTable , $ newTable ) { $ this -> where = $ this -> replaceTableInConditions ( $ this -> where , $ oldTable , $ newTable ) ; $ this -> joins = $ this -> replaceTableInConditions ( $ this -> joins , $ oldTable , $ newTable ) ; if ( $ this -> groupBy ) $ this -> groupBy [ 0 ] = preg_rep... | Replace an alias with a new one in the conditions jointures and group by . |
8,728 | public function values ( $ column ) { $ res = [ ] ; while ( $ row = $ this -> next ( ) ) $ res [ ] = $ row [ $ column ] ; return $ res ; } | Return all values of a column . |
8,729 | public function update ( array $ values ) { $ sql = $ this -> buildUpdateSQL ( $ values ) ; $ params = $ this -> getParameters ( ) ; return $ this -> db -> query ( $ sql , $ params ) -> affected ( ) ; } | Update rows . |
8,730 | public function delete ( array $ tables = [ ] ) { $ sql = $ this -> buildDeleteSQL ( $ tables ) ; $ params = $ this -> getParameters ( ) ; return $ this -> db -> query ( $ sql , $ params ) -> affected ( ) ; } | Delete rows . |
8,731 | protected function _function ( $ fct , $ what = null , $ group_by = null ) { if ( $ what === null ) $ what = '*' ; $ fct = strtoupper ( $ fct ) ; $ clone = clone $ this ; if ( $ fct === 'COUNT' ) { $ clone -> offset ( null ) ; $ clone -> limit ( null ) ; } $ alias = strtolower ( $ fct ) ; if ( $ group_by ) { $ dal = ne... | Execute a math function . |
8,732 | public function count ( $ what = null , $ group_by = null ) { $ r = $ this -> _function ( 'COUNT' , $ what , $ group_by ) ; if ( ! is_array ( $ r ) ) $ r = ( int ) $ r ; return $ r ; } | Count number of rows . |
8,733 | protected function replaceParams ( $ sql , array $ params ) { $ i = 0 ; return preg_replace_callback ( '/\?/' , function ( ) use ( & $ i , $ params , $ sql ) { $ rep = $ params [ $ i ++ ] ; if ( ! $ rep instanceof Raw && ! $ rep instanceof static ) return "'" . addslashes ( $ rep ) . "'" ; else return '?' ; } , $ sql )... | Replace parameters in a SQL query . |
8,734 | public function dbgSelect ( ) { $ sql = $ this -> buildSQL ( ) ; $ params = $ this -> getParameters ( ) ; return $ this -> replaceParams ( $ sql , $ params ) ; } | Compute the sql query for debugging . |
8,735 | public function dbgUpdate ( array $ values ) { $ sql = $ this -> buildUpdateSQL ( $ values ) ; $ params = $ this -> getParameters ( ) ; return $ this -> replaceParams ( $ sql , $ params ) ; } | Compute the update sql query for debugging . |
8,736 | public function dbgInsert ( array $ values , array $ update = [ ] , array $ contraint = [ ] ) { $ sql = $ this -> buildInsertSQL ( [ $ values ] , $ update , $ constraint ) ; $ params = $ this -> getParameters ( ) ; return $ this -> replaceParams ( $ sql , $ params ) ; } | Conpute the insert sql query for debugging . |
8,737 | public function dbgInsertMany ( array $ rows , array $ update = [ ] , array $ constraint = [ ] ) { $ sql = $ this -> buildInsertSQL ( $ rows , $ update , $ constraint ) ; $ params = $ this -> getParameters ( ) ; return $ this -> replaceParams ( $ sql , $ params ) ; } | Conpute the insert many sql query for debugging . |
8,738 | public function dbgDelete ( array $ tables = [ ] ) { $ sql = $ this -> buildDeleteSQL ( $ tables ) ; $ params = $ this -> getParameters ( ) ; return $ this -> replaceParams ( $ sql , $ params ) ; } | Compute the delete sql query for debugging . |
8,739 | protected function verbose ( $ message , $ level ) { if ( $ this -> output -> getVerbosity ( ) >= $ level ) { $ this -> output -> write ( $ message ) ; } } | Verbose output helper . |
8,740 | protected function doesUrlMatchToAtLeastOnePattern ( $ url , array $ patterns ) { foreach ( $ patterns as $ pattern ) { $ regex = '|' . $ pattern . '|' ; $ this -> verbose ( "Checking url '" . $ url . "' with regex '" . $ regex . "' -> " , OutputInterface :: VERBOSITY_VERBOSE ) ; if ( preg_match ( $ regex , $ url ) ) {... | Will return true if the given url matches at least one of the given patterns . |
8,741 | public function generateSortableColumnHeader ( $ params , & $ smarty ) { $ current_order = $ this -> getParam ( $ params , 'current_order' ) ; $ order = $ this -> getParam ( $ params , 'order' ) ; $ reverse_order = $ this -> getParam ( $ params , 'reverse_order' ) ; $ path = $ this -> getParam ( $ params , 'path' ) ; $... | Generates the link of a sortable column header |
8,742 | protected function splash ( $ text , $ hide_splash = false ) { if ( ! $ hide_splash ) { $ this -> line ( '' ) ; $ this -> line ( ' _ _ ' ) ; $ this -> line ( ' / \ __ _ | |_ __ _ | |_ ' ) ; $ this -> line ( " / /\ // _` || __|/ _` |/ __| / _ \| __|/ __|" ) ; $ this... | Display the splash . |
8,743 | protected function getDatasets ( $ dataset = false ) { $ source_packages = config ( 'datasets.source' , [ ] ) ; $ result = [ ] ; foreach ( $ source_packages as $ folder ) { $ datasets = new Filesystem ( new Adapter ( base_path ( 'vendor/' . $ folder . '/datasets/' ) ) ) ; try { $ files = $ datasets -> listContents ( ) ... | Get list of dataset s paths or a specific dataset s path . |
8,744 | protected function loadConfig ( $ dataset ) { $ config_file = $ this -> getDatasets ( $ dataset ) ; $ config = include $ config_file ; $ this -> checkConfig ( $ config ) ; return $ config ; } | Load config file . |
8,745 | protected function checkConfig ( $ config ) { $ required_fields = [ 'namespace' , 'table' , 'path' , 'mapping' , 'import_keys' ] ; foreach ( $ required_fields as $ key ) { if ( ! array_has ( $ config , $ key ) ) { $ this -> error ( sprintf ( 'Missing \'%s\' from the dataset configuration file.' , $ key ) ) ; $ this -> ... | Check config file . |
8,746 | protected function verifyConnection ( ) { if ( count ( config ( 'database.connections' , [ ] ) ) > 1 ) { $ connections = array_keys ( config ( 'database.connections' ) ) ; $ default = array_search ( config ( 'database.default' ) , $ connections ) ; return $ this -> choice ( 'Which connection do we use?' , $ connections... | Request connection or use default . |
8,747 | private function getNextInteration ( ) { $ migrations = new Filesystem ( new Adapter ( base_path ( 'database/migrations' ) ) ) ; try { $ files = $ migrations -> listContents ( ) ; } catch ( \ Exception $ exception ) { $ this -> error ( $ exception -> getMessage ( ) ) ; exit ( 1 ) ; } $ files_filtered = array_filter ( $... | Get the next interation . |
8,748 | public function fullMessage ( ) { if ( $ this -> self ) $ str = ( string ) $ this -> self . ':' ; else $ str = ( string ) $ this -> first ( ) . ':' ; foreach ( $ this -> rules as $ rule ) $ str .= "\n\t" . $ rule ; foreach ( $ this -> attributes as $ attribute ) $ str .= "\n\t" . $ attribute -> first ( ) ; return $ str... | Show the full error message . |
8,749 | public function error ( $ rule = null ) { if ( $ rule === null ) return $ this -> self ; elseif ( isset ( $ this -> rules [ $ rule ] ) ) return $ this -> rules [ $ rule ] ; elseif ( $ attribute = $ this -> attribute ( $ rule ) ) return $ attribute -> error ( ) ; } | Return the error of a rule if provided otherwise the main error . |
8,750 | public function errors ( $ nested = true ) { $ errors = $ this -> rules ; foreach ( $ this -> attributes as $ attribute => $ report ) $ errors [ $ attribute ] = $ nested ? $ report -> errors ( ) : $ report -> error ( ) ; return $ errors ; } | Return an array of rules and attributes errors . |
8,751 | public function first ( $ attribute = null ) { if ( $ attribute !== null ) return $ this -> attribute ( $ attribute ) -> first ( ) ; else { if ( $ this -> rules ) return array_values ( $ this -> rules ) [ 0 ] ; elseif ( $ this -> attributes ) return array_values ( $ this -> attributes ) [ 0 ] -> error ( ) ; } } | Return the first error of the report or of an attribute if provided . |
8,752 | public function failed ( ) { $ failed = [ ] ; foreach ( $ this -> attributes as $ attribute => $ report ) { $ attrFailed = $ report -> failed ( ) ; if ( $ attrFailed ) $ failed [ $ attribute ] = $ attrFailed ; else $ failed [ ] = $ attribute ; } return $ failed ; } | Return the array of failed attributes . |
8,753 | public function attribute ( $ attribute , Report $ report = null ) { if ( is_string ( $ attribute ) ) $ attribute = explode ( '.' , $ attribute ) ; $ next = array_shift ( $ attribute ) ; if ( ! isset ( $ this -> attributes [ $ next ] ) ) $ this -> attributes [ $ next ] = new static ; if ( $ report !== null ) { if ( cou... | Return an attribute report or set one if provided . |
8,754 | protected function searchUrlPatterns ( \ stdClass $ json , array $ patterns ) { $ errors = array ( ) ; foreach ( $ json -> packages as $ package ) { if ( ! isset ( $ package -> source ) ) { $ this -> verbose ( 'Source not found in "' . $ package -> name . "\"\n" , OutputInterface :: VERBOSITY_VERBOSE ) ; $ url = '' ; }... | Will return a array of invalid packages and their urls determined by the given patterns . A url is invalid if NONE of the given patterns has matched . |
8,755 | public function convert ( Email $ email ) : \ Swift_Message { $ message = $ this -> createInstance ( ) -> setSubject ( $ email -> getSubject ( ) ) ; $ message -> setBoundary ( $ boundary = \ md5 ( \ uniqid ( ) ) ) ; $ this -> addAddresses ( $ email , $ message ) ; $ this -> addParts ( $ email , $ message , $ boundary )... | Converts an Email object into a \ Swift_Message object . |
8,756 | protected function addAddresses ( Email $ notification , \ Swift_Message $ email ) { foreach ( $ notification -> getTo ( ) as $ to ) { $ this -> addAddress ( $ email , 'to' , $ to ) ; } foreach ( $ notification -> getCc ( ) as $ cc ) { $ this -> addAddress ( $ email , 'cc' , $ cc ) ; } foreach ( $ notification -> getBc... | Adds to cc bcc and from addresses to the mail object . |
8,757 | protected function addParts ( Email $ notification , \ Swift_Message $ email , string $ boundary ) { $ parts = $ notification -> getParts ( ) ; if ( 1 === \ count ( $ parts ) ) { $ part = \ reset ( $ parts ) ; $ email -> setBody ( $ part -> getContent ( ) , $ part -> getContentType ( ) ) ; if ( $ encoder = $ this -> ge... | Adds body parts to the message . |
8,758 | protected function addAttachments ( Email $ notification , \ Swift_Message $ email ) { foreach ( $ notification -> getAttachments ( ) as $ attachment ) { $ email -> attach ( new \ Swift_Attachment ( $ attachment -> getContent ( ) , $ attachment -> getName ( ) , $ attachment -> getContentType ( ) ) ) ; } } | Adds the attachments to the message . |
8,759 | public function addResult ( Result $ result ) : self { $ handler = $ result -> getHandlerName ( ) ; $ this -> results [ $ handler ] [ ] = $ result ; return $ this ; } | Add a result to the array . |
8,760 | public function all ( ) : array { $ results = [ ] ; \ array_walk_recursive ( $ this -> results , function ( $ v ) use ( & $ results ) { $ results [ ] = $ v ; } ) ; return $ results ; } | Get all Result objects . |
8,761 | private function getTemplate ( ) { if ( $ this -> template ) { return $ this -> template ; } return $ this -> template = $ this -> twig -> load ( '@EkynaCms/Editor/Block/tabs.html.twig' ) ; } | Returns the template . |
8,762 | function initContext ( DocumentContext $ ctx ) { $ ctx -> condenseLiterals = $ this -> collapseWhitespace ; $ ctx -> controllers = $ this -> controllers ; $ ctx -> controllerNamespaces = $ this -> controllerNamespaces ; $ ctx -> registerTags ( $ this -> tags ) ; $ ctx -> setFilterHandler ( $ this -> filterHandler ) ; $... | Configures a DocumentContext from Matisse s configuration settings . |
8,763 | function registerControllers ( ModuleInfo $ moduleInfo , array $ mappings ) { $ ctr = & $ this -> controllers ; foreach ( $ mappings as $ path => $ class ) { $ path = "$moduleInfo->path/{$this->viewEngineSettings->moduleViewsPath()}/$path" ; $ ctr [ $ path ] = $ class ; } return $ this ; } | Registers a map of relative view file paths to PHP controller class names . |
8,764 | function registerMacros ( ModuleInfo $ moduleInfo ) { $ path = "{$this->kernelSettings->baseDirectory}/$moduleInfo->path/{$this->viewEngineSettings->moduleViewsPath()}/$this->moduleMacrosPath" ; if ( fileExists ( $ path ) ) { $ all = FilesystemFlow :: from ( $ path ) -> onlyDirectories ( ) -> map ( function ( \ SplFile... | Registers a module s macros directory along with any immediate sub - directories . |
8,765 | static private function properties ( array $ props ) { return "<h6>Assigned properties</h6><table class=grid>" . str_replace ( [ "'" , '...' ] , [ "<i>'</i>" , '<i>...</i>' ] , implode ( '' , map ( $ props , function ( $ v , $ k ) { return "<tr><th>$k<td>" . ( is_string ( $ v ) ? "'" . htmlspecialchars ( trimText ( $ v... | Returns a formatted properties table . |
8,766 | public function create ( $ subjectOrName ) { if ( ! $ subjectOrName instanceof ContentSubjectInterface && ! ( is_string ( $ subjectOrName ) && 0 < strlen ( $ subjectOrName ) ) ) { throw new InvalidOperationException ( "Excepted instance of ContentSubjectInterface or string." ) ; } $ content = $ this -> editor -> getRep... | Creates a new content . |
8,767 | public function fixContainersPositions ( ContentInterface $ content ) { $ this -> sortChildrenByPosition ( $ content , 'containers' ) ; $ containers = $ content -> getContainers ( ) ; $ position = 0 ; foreach ( $ containers as $ container ) { $ container -> setPosition ( $ position ) ; $ position ++ ; } return $ this ;... | Fix the containers positions . |
8,768 | public static function gatekeeper ( $ ability = null ) { if ( ! isset ( self :: $ currentUser ) ) { return false ; } return self :: $ currentUser -> gatekeeper ( $ ability ) ; } | Check to see if the current user has an ability . |
8,769 | public static function configure ( $ config = [ ] ) { $ defaults = include dirname ( __DIR__ ) . '/conf/defaults.php' ; self :: $ config = array_replace ( $ defaults , $ config ) ; if ( ! isset ( Nymph :: $ driver ) ) { throw new Exception ( 'Tilmeld can\'t be configured before Nymph.' ) ; } HookMethods :: setup ( ) ; ... | Apply configuration to Tilmeld . |
8,770 | public static function fillSession ( $ user ) { if ( ! isset ( self :: $ serverTimezone ) ) { self :: $ serverTimezone = date_default_timezone_get ( ) ; } self :: $ currentUser = $ user ; date_default_timezone_set ( $ user -> getTimezone ( ) ) ; self :: $ currentUser -> updateDataProtection ( ) ; } | Fill session user data . |
8,771 | public static function clearSession ( ) { $ user = self :: $ currentUser ; self :: $ currentUser = null ; if ( isset ( self :: $ serverTimezone ) ) { date_default_timezone_set ( self :: $ serverTimezone ) ; } if ( $ user ) { $ user -> updateDataProtection ( ) ; } } | Clear session user data . |
8,772 | public static function extractToken ( $ token ) { $ extract = self :: $ config [ 'jwt_extract' ] ( $ token ) ; if ( ! $ extract ) { return false ; } $ guid = $ extract [ 'guid' ] ; $ user = Nymph :: getEntity ( [ 'class' => '\Tilmeld\Entities\User' ] , [ '&' , 'guid' => $ guid ] ) ; if ( ! $ user || ! $ user -> guid ||... | Validate and extract the user from a token . |
8,773 | public static function authenticate ( ) { if ( ! empty ( $ _SERVER [ 'HTTP_X_TILMELDAUTH' ] ) && empty ( $ _COOKIE [ 'TILMELDAUTH' ] ) ) { $ fromAuthHeader = true ; $ authToken = $ _SERVER [ 'HTTP_X_TILMELDAUTH' ] ; } elseif ( ! empty ( $ _COOKIE [ 'TILMELDAUTH' ] ) ) { $ fromAuthHeader = false ; $ authToken = $ _COOKI... | Check for a TILMELDAUTH cookie and if set authenticate from it . |
8,774 | public static function login ( $ user , $ sendAuthHeader ) { if ( isset ( $ user -> guid ) && $ user -> enabled ) { $ token = self :: $ config [ 'jwt_builder' ] ( $ user ) ; $ appUrlParts = parse_url ( self :: $ config [ 'app_url' ] ) ; setcookie ( 'TILMELDAUTH' , $ token , time ( ) + self :: $ config [ 'jwt_expire' ] ... | Logs the given user into the system . |
8,775 | public static function logout ( ) { self :: clearSession ( ) ; $ appUrlParts = parse_url ( self :: $ config [ 'app_url' ] ) ; setcookie ( 'TILMELDAUTH' , '' , null , $ appUrlParts [ 'path' ] , $ appUrlParts [ 'host' ] ) ; } | Logs the current user out of the system . |
8,776 | public static function groupSort ( & $ array , $ property = null , $ caseSensitive = false , $ reverse = false ) { Nymph :: hsort ( $ array , $ property , 'parent' , $ caseSensitive , $ reverse ) ; } | Sort an array of groups hierarchically . |
8,777 | public function formatDate ( $ params , $ template = null ) { $ date = $ this -> getParam ( $ params , "date" , false ) ; if ( $ date === false ) { $ timestamp = $ this -> getParam ( $ params , "timestamp" , false ) ; if ( $ timestamp === false ) { throw new SmartyPluginException ( "Either date or timestamp is a mandat... | return date in expected format |
8,778 | public function formatTwoDimensionalArray ( $ params ) { $ output = '' ; $ values = $ this -> getParam ( $ params , "values" , null ) ; $ separators = $ this -> getParam ( $ params , "separators" , [ ' : ' , ' / ' , ' | ' ] ) ; if ( ! is_array ( $ values ) ) { return $ output ; } foreach ( $ values as $ key => $ value ... | return two - dimensional arrays in string |
8,779 | public function generateSlideShows ( ) { foreach ( $ this -> names as $ tag => $ name ) { $ this -> output -> write ( sprintf ( '- <comment>%s</comment> %s ' , $ name , str_pad ( '.' , 44 - mb_strlen ( $ name ) , '.' , STR_PAD_LEFT ) ) ) ; if ( null !== $ slideShow = $ this -> findSlideShowByTag ( $ tag ) ) { $ this ->... | Generates the slide shows based on configuration . |
8,780 | private function getColor ( array $ notes , $ noteIndex ) { if ( ! is_integer ( $ noteIndex ) || ! array_key_exists ( $ noteIndex , $ notes ) ) { return null ; } $ noteObj = $ notes [ $ noteIndex ] ; if ( ! is_object ( $ noteObj ) || ! property_exists ( $ noteObj , 'color' ) ) { return null ; } return $ noteObj -> colo... | Retrieves color for note index |
8,781 | private function getExposent ( $ noteIndex ) { $ footNote = $ this -> getFootNote ( $ noteIndex ) ; if ( empty ( $ footNote ) ) { return null ; } return $ footNote ; } | Retrieves exposent by note index |
8,782 | private function colorizeMminute ( $ minute = '' , array $ colors = [ ] ) { $ cleanedColors = array_filter ( $ colors ) ; if ( empty ( $ cleanedColors ) ) { return $ minute ; } return sprintf ( '<span class="block-color" style="background-color: %s">%s</span>' , current ( $ cleanedColors ) , $ minute ) ; } | Adds background color to the minute string |
8,783 | private function addExponents ( $ minute = '' , array $ exponents = [ ] , $ notesType = null ) { $ cleanedExposents = array_filter ( $ exponents ) ; $ exposantsNb = count ( $ cleanedExposents ) ; if ( $ notesType == LayoutConfig :: NOTES_TYPE_COLOR && $ exposantsNb < 2 ) { return $ minute ; } array_walk ( $ cleanedExpo... | Adds exponents to the minute string if note type isnot color |
8,784 | public function setCloseOnError ( $ close ) { if ( ! is_bool ( $ close ) ) { throw new \ Plop \ Exception ( 'Invalid value' ) ; } $ this -> closeOnError = $ close ; return $ this ; } | Set whether the socket must be closed automatically on error . |
8,785 | public function setInitialRetryDelay ( $ delay ) { if ( ! ( is_int ( $ delay ) || is_float ( $ delay ) ) || $ delay < 0 ) { throw new \ Plop \ Exception ( 'Invalid value' ) ; } $ this -> retryStart = $ delay ; return $ this ; } | Set the delay for the initial reconnection attempt . |
8,786 | public function setRetryFactor ( $ factor ) { if ( ! ( is_int ( $ factor ) || is_float ( $ factor ) ) || $ factor < 1 ) { throw new \ Plop \ Exception ( 'Invalid value' ) ; } $ this -> retryFactor = $ factor ; return $ this ; } | Set the factor applied to the delay between each reconnection attempt . |
8,787 | public function setMaximumRetryDelay ( $ max ) { if ( ! ( is_int ( $ max ) || is_float ( $ max ) ) || $ max < 0 ) { throw new \ Plop \ Exception ( 'Invalid value' ) ; } $ this -> retryMax = $ max ; return $ this ; } | Set the maximum delay between reconnection attempts . |
8,788 | protected function makeSocket ( $ timeout = 1 ) { return fsockopen ( 'tcp://' . $ this -> host , $ this -> port , $ errno , $ errstr , $ timeout ) ; } | Really create a new socket . |
8,789 | protected function createSocket ( ) { $ now = $ this -> getCurrentTime ( ) ; if ( $ this -> retryTime === null ) { $ attempt = true ; } else { $ attempt = ( $ now >= $ this -> retryTime ) ; } if ( ! $ attempt ) { return ; } $ this -> socket = $ this -> makeSocket ( ) ; if ( $ this -> socket !== false ) { $ this -> retr... | Create a new socket taking into account things like retry attempts and delays . |
8,790 | protected function send ( $ s ) { if ( ! $ this -> socket ) { $ this -> createSocket ( ) ; } if ( ! $ this -> socket ) { return false ; } $ written = 0 ; while ( $ s != '' ) { $ written = $ this -> write ( $ s ) ; if ( $ written === false ) { throw new \ Plop \ Exception ( 'Connection lost' ) ; } $ s = ( string ) subst... | Send the given string over the wire . |
8,791 | protected function makePickle ( \ Plop \ RecordInterface $ record ) { $ s = serialize ( $ record ) ; $ slen = pack ( 'N' , strlen ( $ s ) ) ; return $ slen . $ s ; } | Serialize and format a log record so that it can be sent through the wire . |
8,792 | public function setActiveTheme ( $ themeName = '' ) { Event :: fire ( 'theme.before_is_set' , [ $ this ] ) ; if ( $ themeName ) { if ( ! self :: ifExists ( $ themeName ) ) { throw new \ Exception ( $ themeName . ' Theme could not be found in file directory.' ) ; } } else { if ( settings ( 'activateMobileTheme' ) && ( ... | Get active theme . |
8,793 | public static function getConfig ( $ themeDirectory ) { $ getConfigValues = [ ] ; if ( is_dir ( $ themeDirectory ) ) { $ path = $ themeDirectory . '/config.json' ; } else { $ path = base_path ( ) . "/themes/" . $ themeDirectory . '/config.json' ; } if ( file_exists ( $ path ) ) { $ getConfigValues = json_decode ( file_... | Get theme configuration . |
8,794 | public static function getNamespaceOf ( $ themeDirectoryName ) { if ( self :: ifExists ( $ themeDirectoryName ) ) { $ themeConfig = self :: getConfig ( $ themeDirectoryName ) ; if ( isset ( $ themeConfig [ 'namespace' ] ) ) { return "Themes\\" . $ themeConfig [ 'namespace' ] ; } } return null ; } | Get namespace of a specific theme . |
8,795 | public static function view ( $ view , $ itemID = null ) { $ baseViewsPath = self :: getActiveTheme ( ) . '/views/' . $ view ; $ newView = '-' . $ itemID ; if ( $ itemID && self :: viewExists ( $ view . $ newView ) ) { return $ baseViewsPath . $ newView ; } $ newView = '-' . Request :: route ( 'postSlug' ) ; if ( Reque... | Get template view . |
8,796 | public static function configs ( ) { $ files = File :: allFiles ( base_path ( ) . '/themes' ) ; $ result = [ ] ; foreach ( $ files as $ file ) { if ( $ file -> getBasename ( ) == "config.json" ) { $ result [ ] = self :: getConfig ( $ file -> getPath ( ) ) ; } } return $ result ; } | Gets configs of all themes . |
8,797 | public static function mock ( string $ function ) : MockedFunction { $ mock = new MockedFunction ( $ function ) ; self :: $ mocks [ ] = $ mock ; $ closure = new ClosureGenerator ( $ function ) ; uopz_set_return ( $ function , $ closure -> generate ( ) , true ) ; return $ mock ; } | Set up a core function to be mocked . |
8,798 | public static function call ( string $ function , Arguments $ arguments ) { $ mocks = self :: $ mocks ; $ mocks = array_filter ( $ mocks , function ( MockedFunction $ mock ) use ( $ function ) { return $ mock -> getFunctionName ( ) === $ function ; } ) ; foreach ( $ mocks as $ mock ) { if ( $ mock -> matchArguments ( $... | Call the mocked version of a function . |
8,799 | public static function close ( ) : void { $ mocks = self :: $ mocks ; self :: $ mocks = [ ] ; foreach ( $ mocks as $ mock ) { uopz_unset_return ( $ mock -> getFunctionName ( ) ) ; } foreach ( $ mocks as $ mock ) { $ function = $ mock -> getFunctionName ( ) ; $ arguments = $ mock -> getArguments ( ) ; $ times = $ mock -... | Finish the mocking check for any expectations and restore any mocked functions . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.