idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
54,100 | public function insertEscaped ( ... $ field_values ) { if ( $ this -> is_done ) { throw new RuntimeException ( 'This batch insert is already done' ) ; } if ( count ( $ field_values ) == $ this -> fields_num ) { $ this -> rows [ ] = '(' . implode ( ', ' , $ field_values ) . ')' ; $ this -> checkAndInsert ( ) ; } else { ... | Insert array of already escaped values . |
54,101 | public function flush ( ) { if ( $ this -> is_done ) { throw new RuntimeException ( 'This batch insert is already done' ) ; } $ count_rows = count ( $ this -> rows ) ; if ( $ count_rows > 0 ) { $ this -> connection -> execute ( $ this -> sql_foundation . implode ( ', ' , $ this -> rows ) ) ; $ this -> rows = [ ] ; $ th... | Insert rows that are already loaded . |
54,102 | public function done ( ) { if ( $ this -> is_done ) { throw new RuntimeException ( 'This batch insert is already done' ) ; } $ this -> flush ( ) ; $ this -> is_done = true ; return $ this -> total ; } | Finish with the batch . |
54,103 | public function reset ( string $ path ) { if ( ! empty ( $ this -> cache ) ) { $ this -> cache -> resetPath ( $ path ) ; } $ engine = $ this -> findEngine ( $ path ) ; $ generator = new ContextGenerator ( $ this -> context ) ; foreach ( $ generator -> generate ( ) as $ context ) { $ engine -> reset ( $ path , $ context... | Reset view cache for a given path . Identical to compile method by effect but faster . |
54,104 | public function get ( string $ path ) : ViewInterface { if ( ! empty ( $ this -> cache ) && $ this -> cache -> has ( $ this -> context , $ path ) ) { return $ this -> cache -> get ( $ this -> context , $ path ) ; } $ view = $ this -> findEngine ( $ path ) -> get ( $ path , $ this -> context ) ; if ( ! empty ( $ this ->... | Get view from one of the associated engines . |
54,105 | protected function _createFile ( ) { do { $ this -> _filename = $ this -> getPath ( ) . mt_rand ( ) . '.html' ; } while ( File :: exists ( $ this -> _filename ) ) ; File :: put ( $ this -> _filename , $ this -> getHtml ( ) ) ; chmod ( $ this -> _filename , 0777 ) ; return $ this -> _filename ; } | creates file to which will be writen html content |
54,106 | public function setPath ( $ path ) { if ( realpath ( $ path ) === false ) { throw new Exception ( "Path must be absolute." ) ; } $ this -> _path = realpath ( $ path ) . DS ; return $ this ; } | Absolute path where to store files |
54,107 | protected function _getCommand ( ) { $ command = $ this -> _bin ; $ command .= ( $ this -> getCopies ( ) > 1 ) ? " --copies " . $ this -> getCopies ( ) : "" ; $ command .= " --orientation " . $ this -> getOrientation ( ) ; $ command .= " --page-size " . $ this -> getPageSize ( ) ; foreach ( $ this -> getMargins ( ) as ... | returns command to execute |
54,108 | private function initHelper ( ) { if ( ! $ this -> isConfigFileSet ( ) ) { throw new Exception ( "The main config file wasn't defined." ) ; } if ( ! $ this -> isAppRootSet ( ) ) { throw new Exception ( "The application root wasn't defined." ) ; } AppHelper :: getInstance ( ) -> setAppRoot ( $ this -> getAppRoot ( ) ) -... | It inits the application helper . |
54,109 | public function getUsers ( ) { $ tmp = array ( ) ; foreach ( $ this -> htpwd as $ key => $ line ) { if ( empty ( $ line ) || ! strpos ( $ line , ':' ) ) continue ; array_push ( $ tmp , explode ( ":" , $ line ) [ 0 ] ) ; } return $ tmp ; } | Gets all users . |
54,110 | public function addUser ( $ user , $ pass ) { if ( ! empty ( $ user ) && ! $ this -> userExists ( $ user ) && ! empty ( $ pass ) ) { array_push ( $ this -> htpwd , $ user . ':' . crypt ( $ pass , substr ( str_replace ( '+' , '.' , base64_encode ( pack ( 'N4' , mt_rand ( ) , mt_rand ( ) , mt_rand ( ) , mt_rand ( ) ) ) )... | Adds a user . |
54,111 | private function _save ( ) { unlink ( $ this -> path ) ; file_put_contents ( $ this -> path , join ( '\n' , $ this -> htpwd ) ) ; } | Saves the . htpasswd file contents . |
54,112 | protected function _loadLanguageStrings ( $ throw_errors = true , $ force_rebuild = false , $ force_rebuild_on_update = false ) { $ _fn = $ this -> getLoader ( ) -> buildLanguageFileName ( $ this -> lang ) ; $ _f = $ this -> getLoader ( ) -> buildLanguageFilePath ( $ this -> lang ) ; if ( isset ( $ this -> language_str... | Load the current language strings |
54,113 | protected function _rebuildLanguageStringsFiles ( ) { $ db_filepath = $ this -> getLoader ( ) -> buildLanguageDBFilePath ( ) ; $ generator = new Generator ( $ db_filepath ) ; $ generator -> generate ( ) ; return $ this ; } | Rebuild the language strings databases with I18n \ Generator |
54,114 | public function loadFile ( $ file_name , $ dir_name = null ) { try { $ loader = $ this -> getLoader ( ) ; $ file_path = $ loader -> findLanguageDBFile ( ! empty ( $ file_name ) ? basename ( $ file_name ) : $ file_name , ! empty ( $ dir_name ) ? $ dir_name : ( ! empty ( $ file_name ) ? dirname ( $ file_name ) : $ dir_na... | Load a new language file |
54,115 | public function setLanguage ( $ lang , $ throw_errors = true , $ force_rebuild = false ) { if ( $ this -> isAvailableLanguage ( $ lang ) ) { $ this -> lang = $ lang ; $ this -> setLocale ( $ this -> getAvailableLocale ( $ lang ) ) ; $ this -> _loadLanguageStrings ( $ throw_errors , $ force_rebuild ) ; } else { throw ne... | Loads a new language |
54,116 | public function setDefaultFromHttp ( ) { $ http_locale = $ this -> getHttpHeaderLocale ( ) ; if ( ! empty ( $ http_locale ) && $ this -> isAvailableLanguage ( $ http_locale ) ) { $ this -> setLanguage ( $ http_locale ) ; } return $ this ; } | Try to get the browser default locale and use it |
54,117 | public function isAvailableLanguage ( $ lang ) { return array_key_exists ( $ lang , $ this -> getLoader ( ) -> getOption ( 'available_languages' ) ) || in_array ( $ lang , $ this -> getLoader ( ) -> getOption ( 'available_languages' ) ) ; } | Check if a language code is available in the Loader |
54,118 | public function getAvailableLocale ( $ lang ) { $ langs = $ this -> getLoader ( ) -> getOption ( 'available_languages' ) ; if ( array_key_exists ( $ lang , $ langs ) ) { return $ langs [ $ lang ] ; } elseif ( in_array ( $ lang , $ langs ) ) { return $ langs [ array_search ( $ lang , $ langs ) ] ; } return null ; } | Get the full locale info for a language code |
54,119 | public function getLocalizedString ( $ index ) { return isset ( $ this -> language_strings [ $ index ] ) ? $ this -> language_strings [ $ index ] : $ index ; } | Get the translation of an index |
54,120 | public function parseString ( $ str , array $ arguments = null ) { if ( empty ( $ arguments ) ) { return $ str ; } $ arg_mask = $ this -> getLoader ( ) -> getOption ( 'arg_wrapper_mask' ) ; foreach ( $ arguments as $ name => $ value ) { if ( is_string ( $ name ) ) { $ str = strtr ( $ str , array ( sprintf ( $ arg_mask ... | Parse a translated string making some parameters replacements |
54,121 | public function parseStringMetadata ( $ str ) { $ info = array ( ) ; if ( 0 !== preg_match ( '~^\[([^\]]+)\]~i' , $ str , $ matches ) ) { $ str = str_replace ( $ matches [ 0 ] , '' , $ str ) ; $ types = $ matches [ 1 ] ; $ types_items = explode ( ';' , $ types ) ; foreach ( $ types_items as $ item ) { $ parts = explode... | Get the meta - data of a language string |
54,122 | protected function _showUntranslated ( $ str = '' , array $ args = null ) { $ arguments = '' ; if ( ! empty ( $ args ) ) { foreach ( $ args as $ var => $ val ) { $ arguments .= '"' . $ var . '" => ' . str_replace ( array ( "\n" , "\t" ) , '' , var_export ( $ val , 1 ) ) . ', ' ; } } return sprintf ( $ this -> getLoader... | Special function to show a string when its translation doesn t exist |
54,123 | public function getCurrency ( $ lang = null ) { if ( ! is_null ( $ lang ) ) { $ original_lang = $ this -> getLanguage ( ) ; $ this -> setLanguage ( $ lang ) ; } $ formatter = new NumberFormatter ( $ this -> getLocale ( ) , NumberFormatter :: CURRENCY ) ; $ currency = $ formatter -> getTextAttribute ( NumberFormatter ::... | Get the currency of the current locale |
54,124 | public function getLanguageCode ( $ lang = null ) { $ parts = $ this -> _callInternalLocale ( 'parseLocale' , null , $ lang , false ) ; return isset ( $ parts [ 'language' ] ) ? $ parts [ 'language' ] : null ; } | Get the language code of the current locale |
54,125 | public function getKeyword ( $ keyword , $ lang = null ) { $ parts = $ this -> _callInternalLocale ( 'getKeywords' , null , $ lang , false ) ; return isset ( $ parts [ $ keyword ] ) ? $ parts [ $ keyword ] : null ; } | Get one keyword value of the current locale |
54,126 | protected function _callInternalLocale ( $ fct_name , $ for_locale = null , $ lang = null , $ do_array = true ) { if ( ! is_null ( $ lang ) ) { $ original_lang = $ this -> getLanguage ( ) ; $ this -> setLanguage ( $ lang ) ; } $ locale = ! is_null ( $ for_locale ) ? $ this -> getAvailableLocale ( $ for_locale ) : $ thi... | Internally factorize the Locale methods |
54,127 | public static function getLocalizedPriceString ( $ number , $ lang = null ) { $ _this = self :: getInstance ( ) ; if ( ! is_null ( $ lang ) ) { $ original_lang = $ _this -> getLanguage ( ) ; $ _this -> setLanguage ( $ lang ) ; } $ formatter = new NumberFormatter ( $ _this -> getLocale ( ) , NumberFormatter :: CURRENCY ... | Get a localized price value |
54,128 | public static function getLocalizedDateString ( DateTime $ date , $ mask = null , $ charset = 'UTF-8' , $ lang = null ) { $ _this = self :: getInstance ( ) ; if ( ! is_null ( $ lang ) ) { $ original_lang = $ _this -> getLanguage ( ) ; $ _this -> setLanguage ( $ lang ) ; } if ( is_null ( $ mask ) ) { $ mask = $ _this ->... | Get a localized date value |
54,129 | public static function translate ( $ index , array $ args = null , $ lang = null ) { $ _this = self :: getInstance ( ) ; if ( ! is_null ( $ lang ) ) { $ original_lang = $ _this -> getLanguage ( ) ; $ _this -> setLanguage ( $ lang ) ; } if ( $ _this -> hasLocalizedString ( $ index ) ) { $ str = $ _this -> getLocalizedSt... | Process a translation with arguments |
54,130 | public static function pluralize ( array $ indexes = array ( ) , $ number = 0 , array $ args = null , $ lang = null ) { $ _this = self :: getInstance ( ) ; $ args [ 'nb' ] = $ number ; if ( isset ( $ indexes [ $ number ] ) ) { return self :: translate ( $ indexes [ $ number ] , $ args , $ lang ) ; } $ str = ( $ number ... | Process a translation with arguments depending on a counter |
54,131 | public function is ( string $ key ) : bool { return isset ( $ this -> meta [ $ key ] ) && ( bool ) $ this -> meta [ $ key ] ; } | Check if meta for given key exists and is not false |
54,132 | public function check ( $ user , $ permissions , $ resourceName = null , $ resourceId = null ) { return $ this -> manager -> caller ( $ user ) -> can ( $ permissions , $ resourceName , ( int ) $ resourceId ) ; } | Check the given user has the given permission . |
54,133 | public function can ( $ permissions , $ resourceName = null , $ resourceId = null ) { return $ this -> caller ( ) -> can ( $ permissions , $ resourceName , $ resourceId ) ; } | Perform check on the subject . |
54,134 | public function all ( ) { if ( $ this -> subject == 'user' ) { return $ this -> getUserPermissions ( $ this -> user ) ; } elseif ( $ this -> subject == 'role' ) { return $ this -> getRolePermissions ( $ this -> role ) ; } } | Return all specific permissions for the given subject . |
54,135 | public function grant ( $ permissions , $ resourceName = null , $ resourceId = null ) { return $ this -> lock ( ) -> allow ( $ permissions , $ resourceName , $ resourceId ) ; } | Grant the given permissions to the given subject . |
54,136 | public function revoke ( $ permissions , $ resourceName = null , $ resourceId = null ) { return $ this -> lock ( ) -> deny ( $ permissions , $ resourceName , $ resourceId ) ; } | Revoke the given permissions from the given subject . |
54,137 | protected function caller ( ) { if ( $ this -> subject == 'user' ) { return $ this -> manager -> caller ( $ this -> user ) ; } elseif ( $ this -> subject == 'role' ) { return $ this -> manager -> role ( $ this -> role ) ; } return null ; } | Return the caller to work on . |
54,138 | protected function lock ( ) { if ( $ this -> subject == 'user' ) { return $ this -> manager -> caller ( $ this -> user ) ; } elseif ( $ this -> subject == 'role' ) { return $ this -> manager -> role ( $ this -> role ) ; } else { throw new \ Exception ( "Caller not allowed: $this->subject" ) ; } } | Return the lock instance to work on . |
54,139 | protected function getUserPermissions ( $ user ) { $ permissions = $ this -> manager -> getDriver ( ) -> getCallerPermissions ( $ user ) ; $ collection = new Collection ( ) ; foreach ( $ permissions as $ permission ) { if ( $ permission instanceof Restriction ) { continue ; } $ collection -> allow ( $ permission -> get... | Return a collection of user based permissions . |
54,140 | protected function getRolePermissions ( $ roleName ) { $ role = new SimpleRole ( $ roleName ) ; $ permissions = $ this -> manager -> getDriver ( ) -> getRolePermissions ( $ role ) ; $ collection = new Collection ( ) ; foreach ( $ permissions as $ permission ) { if ( $ permission instanceof Restriction ) { continue ; } ... | Return a collection of role based permissions . |
54,141 | public function build ( ContainerBuilder $ container ) { parent :: build ( $ container ) ; $ configFile = new SplFileInfo ( ( new FileLocator ( $ this -> getPath ( ) . '/Resources/config' ) ) -> locate ( 'synapse.yml' ) , '' , '' ) ; $ container -> addCompilerPass ( new CompilerPass ( Yaml :: parse ( $ configFile -> ge... | override build to register theme configuration . |
54,142 | public static function createFromConfiguration ( $ role , array $ configuration ) { return new Role ( $ role , isset ( $ configuration [ "title" ] ) ? $ configuration [ "title" ] : null , isset ( $ configuration [ "description" ] ) ? $ configuration [ "description" ] : null , isset ( $ configuration [ "hidden" ] ) ? $ ... | Creates the role from the configuration |
54,143 | protected function getValidPriority ( $ desiredPriority ) { $ desiredPriority = ( int ) $ desiredPriority * 10000 ; if ( ! in_array ( $ desiredPriority , $ this -> allocatedPriorities ) ) { return $ desiredPriority ; } $ increment = 1 ; while ( in_array ( $ desiredPriority , $ this -> allocatedPriorities ) ) { $ desire... | Get a valid priority number to attach to a filter |
54,144 | public function cropFromEdge ( $ cropWidth , $ cropHeight = null , $ edge = 0 ) { if ( $ cropHeight === null ) { $ cropHeight = $ cropWidth ; } $ cropWidth = ( $ this -> _sourceWidth < $ cropWidth ) ? $ this -> _sourceWidth : $ cropWidth ; $ cropHeight = ( $ this -> _sourceHeight < $ cropHeight ) ? $ this -> _sourceHei... | Crop a picture from a given edge |
54,145 | public static function getResourceGroup ( $ name ) { $ group = FALSE ; if ( is_array ( $ name ) ) { $ count = count ( $ name ) ; if ( $ count < 1 || $ count > 2 ) { throw new Exception ( 'You must only pass the resource group and name for a resource.' ) ; } else if ( $ count == 1 ) { $ name = $ name [ 0 ] ; } else { $ ... | Return a resource group and name given a name variable |
54,146 | public static function newResource ( $ name , $ resource , $ select = FALSE , $ overrride = FALSE , $ default = TRUE ) { list ( $ group , $ name ) = self :: getResourceGroup ( $ name ) ; if ( isset ( self :: $ resources [ $ group ] [ $ name ] ) && ! $ overrride ) { throw new Exception ( 'The ' . ( $ group ? $ group . '... | Set a new framework resource |
54,147 | public static function newResources ( $ group , $ resources , $ setDefault = TRUE , $ defaultOverride = FALSE ) { foreach ( $ resources as $ resource ) { $ select = FALSE ; $ name = FALSE ; $ override = $ defaultOverride ; if ( is_object ( $ resource ) ) { $ obj = $ resource ; } elseif ( ! is_array ( $ resource ) || ! ... | Set a group of framework resources |
54,148 | public static function removeResource ( $ group , $ name = FALSE ) { if ( $ name ) { unset ( self :: $ resources [ $ group ] [ $ name ] ) ; if ( self :: getGroupSetting ( $ group , 'default' ) == $ name ) { self :: removeDefault ( $ group ) ; } } else { unset ( self :: $ resources [ $ group ] ) ; } if ( self :: countRe... | Delete resource or resource group |
54,149 | public static function & getResource ( $ name ) { list ( $ group , $ name ) = self :: getResourceGroup ( $ name ) ; if ( ! isset ( self :: $ resources [ $ group ] [ $ name ] ) ) { $ bln = FALSE ; return $ bln ; } return self :: $ resources [ $ group ] [ $ name ] ; } | Return a framework resource reference |
54,150 | public static function getSelectedResources ( ) { $ resources = array ( ) ; foreach ( array_keys ( self :: $ resourceSettings ) as $ group ) { $ resources [ $ group ] = & self :: getResource ( array ( $ group , self :: getGroupSetting ( $ group , 'default' ) ) ) ; } return $ resources ; } | Return an array of reference resource objects which are currently selected |
54,151 | public static function & getSelectedResource ( $ group ) { if ( ! isset ( self :: $ resources [ $ group ] ) || ! self :: getGroupSetting ( $ group , 'default' ) ) { $ bln = FALSE ; return $ bln ; } return self :: getResource ( array ( $ group , self :: getGroupSetting ( $ group , 'default' ) ) ) ; } | Return the currently selected resource for a resource group |
54,152 | public static function setSelectedResource ( $ group , $ name ) { if ( ! isset ( self :: $ resources [ $ group ] [ $ name ] ) ) { return FALSE ; } self :: setGroupSetting ( $ group , 'default' , $ name ) ; return TRUE ; } | Set the selected resource for a resource group |
54,153 | public static function selectRandomResource ( $ group ) { if ( ! isset ( self :: $ resources [ $ group ] ) ) { $ bln = FALSE ; return $ bln ; } return array_rand ( self :: $ resources [ $ group ] ) ; } | Return a random group resource name |
54,154 | public static function countResourceGroup ( $ group ) { return isset ( self :: $ resources [ $ group ] ) ? count ( self :: $ resources [ $ group ] ) : 0 ; } | Return number of resource in a group |
54,155 | public static function getGroupSetting ( $ group , $ setting ) { return isset ( self :: $ resourceSettings [ $ group ] [ $ setting ] ) ? self :: $ resourceSettings [ $ group ] [ $ setting ] : FALSE ; } | Return group setting or FALSE if not set |
54,156 | public function startWithNode ( $ name , $ nodes ) { if ( ! is_array ( $ nodes ) ) { $ nodes = array ( $ nodes ) ; } $ parts = array ( ) ; foreach ( $ nodes as $ key => $ node ) { $ fullKey = $ name . '_' . $ key ; $ parts [ ] = ":$fullKey" ; $ this -> set ( $ fullKey , $ node ) ; } $ parts = implode ( ', ' , $ parts )... | Adds nodes to the queries start clause . |
54,157 | public function startWithLookup ( $ name , $ index , $ key , $ value ) { $ this -> start ( "$name = node:`$index`($key = :{$name}_{$key})" ) ; $ this -> set ( "{$name}_{$key}" , $ value ) ; return $ this ; } | Adds a node lookup to the queries start clause . |
54,158 | public function set ( $ name , $ value ) { if ( is_object ( $ value ) && method_exists ( $ value , 'getId' ) ) { $ this -> parameters [ $ name ] = $ value -> getId ( ) ; } else { $ this -> parameters [ $ name ] = $ value ; } return $ this ; } | Sets named query parameters . |
54,159 | public function getOne ( ) { $ result = $ this -> execute ( ) ; if ( isset ( $ result [ 0 ] ) ) { return $ this -> convertValue ( $ result [ 0 ] [ 0 ] ) ; } return null ; } | Executes the query and returns one result . |
54,160 | public function getList ( ) { $ result = $ this -> execute ( ) ; $ list = new ArrayCollection ; foreach ( $ result as $ row ) { $ list -> add ( $ this -> convertValue ( $ row [ 0 ] ) ) ; } return $ list ; } | Executes the query and returns a list of results as entities . |
54,161 | public function getResult ( ) { $ result = $ this -> execute ( ) ; $ list = new ArrayCollection ; foreach ( $ result as $ row ) { $ entry = array ( ) ; foreach ( $ row as $ key => $ value ) { $ entry [ $ key ] = $ this -> convertValue ( $ value ) ; } $ list -> add ( $ entry ) ; } return $ list ; } | Executes the query and returns a array collection of assoc . arrays without converting them to entities . |
54,162 | private function processParameters ( ) { $ parameters = $ this -> parameters ; $ string = $ this -> query ; $ string = str_replace ( '[:' , '[;;' , $ string ) ; $ parameters = array_filter ( $ parameters , function ( $ value ) use ( & $ parameters , & $ string ) { $ key = key ( $ parameters ) ; next ( $ parameters ) ; ... | Processes parameters and returns an array of them afterwards . |
54,163 | protected function compare ( $ schedule1 , $ schedule2 ) { $ run1 = $ schedule1 -> getNextRunDate ( ) ; $ run2 = $ schedule2 -> getNextRunDate ( ) ; if ( $ run1 < $ run2 ) { return 1 ; } elseif ( $ run1 > $ run2 ) { return - 1 ; } return 0 ; } | Compare the schedules the one with the first nextRunDate will be added at the beginning of the list . |
54,164 | protected function delete_assignment ( ) { $ uri = str_replace ( '{assignment}' , $ this -> assignment , config ( 'forge-publish.update_assignment_uri' ) ) ; $ url = config ( 'forge-publish.url' ) . $ uri ; try { $ response = $ this -> http -> delete ( $ url , [ 'headers' => [ 'X-Requested-With' => 'XMLHttpRequest' , '... | Delete assignment . |
54,165 | public static function fromMessage ( Message $ msg ) { $ workerHandlerId = $ msg -> shift ( ) ; $ requestId = $ msg -> shift ( ) ; if ( ! $ requestId ) { $ requestId = null ; } return new self ( $ workerHandlerId , $ requestId ) ; } | Creates an instance based on the Message . |
54,166 | public function run ( ) { $ this -> tryAssignController ( ) ; if ( ! $ this -> isControllerAssigned ( ) ) { throw new Exception ( "It's unable to assign controller to this route path." ) ; } $ oCtrl = $ this -> createCtrl ( ) ; $ oCtrl -> { $ this -> actionName } ( $ this -> actionArgs ) ; } | It executes the action of controller . |
54,167 | private function writeArray ( array $ array , $ depth , $ comments = false ) { $ isIndexed = array_values ( $ array ) === $ array ; $ method = $ comments ? 'writeComment' : 'writeLine' ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ val = '' ; } else { $ val = $ value ; } $ key = $ this -> s... | Output an array . |
54,168 | private function outputExamples ( $ depth ) { if ( is_array ( $ this -> example ) ) { $ message = count ( $ this -> example ) > 1 ? 'Examples' : 'Example' ; $ this -> writeComment ( $ message . ':' , $ depth * 4 + 4 ) ; $ this -> writeArray ( $ this -> example , $ depth * 4 + 4 , true ) ; } } | Output the node s examples . |
54,169 | private function outputDefaults ( $ depth ) { if ( $ this -> defaultArray ) { $ message = count ( $ this -> defaultArray ) > 1 ? 'Defaults' : 'Default' ; $ childDepth = $ depth * 4 + 4 ; $ this -> writeComment ( $ message . ':' , $ childDepth ) ; $ this -> writeArray ( $ this -> defaultArray , $ childDepth ) ; } } | Output the node s default value . |
54,170 | private function outputChildren ( $ children , $ depth ) { if ( $ children ) { foreach ( $ children as $ childNode ) { if ( $ childNode -> getInfo ( ) === 'Prototype' ) { $ childNode -> setInfo ( '' ) ; $ hasChildren = ! $ childNode instanceof ArrayNode || ! $ childNode -> getChildren ( ) ; $ this -> writeNode ( $ chil... | Output the children of the node . |
54,171 | private function _newRound ( ) { $ environment_factory = EnvironmentFactory :: Get ( ) ; if ( ! in_array ( RoundBasedEnvironmentFactory :: class , class_parents ( $ environment_factory ) ) ) { throw RuntimeException :: EnvironmentFactoryIsNotRoundBased ( ) ; } return $ environment_factory -> newRound ( $ this -> _curre... | Returns a new round generated by the EnvironmentFactory object . |
54,172 | public function addRound ( ) { ++ $ this -> _currentRoundNo ; $ new_round = $ this -> _newRound ( ) ; $ this -> _rounds -> offsetSet ( $ this -> _currentRoundNo , $ new_round ) ; return $ new_round ; } | Creates the next round and returns the new current round . |
54,173 | public function parse ( ) { $ time = time ( ) ; $ gmdate = gmdate ( 'D, d M Y H:i:s' , $ time ) ; Container :: get ( 'response' ) -> setHeader ( 'MDE-Version' , \ MarkdownExtended \ MarkdownExtended :: MDE_VERSION ) -> setHeader ( 'Last-Modified' , $ gmdate . ' GMT' ) ; $ etag = '' ; $ sources = $ this -> getSources ( ... | Parse the sources contents |
54,174 | public function serve ( ) { $ type = $ this -> getSourceType ( ) ; $ sources = $ this -> getSources ( ) ; $ contents = $ this -> getContents ( ) ; if ( $ type != 'file' && count ( $ sources ) == 1 ) { $ response_data = array ( 'source' => $ sources [ 0 ] , 'content' => $ contents [ 0 ] , ) ; } else { $ response_data = ... | Serve the JSON response and exit |
54,175 | public function warning ( $ str , $ status = Response :: STATUS_OK ) { $ this -> addError ( new Error ( $ str , $ status ) ) ; return $ this ; } | Add a simple not - fatal error message |
54,176 | public function error ( $ str , $ code = Response :: STATUS_ERROR ) { $ this -> addError ( new Error ( $ str , $ code ) ) ; Container :: get ( 'response' ) -> setStatus ( $ code ) ; if ( ! Container :: get ( 'response' ) -> isStatus ( Response :: STATUS_OK ) ) { $ this -> serve ( ) ; } } | Handle errors adding the error message to the response and serving it if needed |
54,177 | public static function bySerializedContentType ( $ contentType ) { switch ( $ contentType ) { case PhpSerializer :: SERIALIZED_CONTENT_TYPE : $ serializer = new PhpSerializer ( ) ; break ; case JsonSerializer :: SERIALIZED_CONTENT_TYPE : $ serializer = new JsonSerializer ( ) ; break ; case NullSerializer :: SERIALIZED_... | Creates a Serializer for the given content type . |
54,178 | protected function getPublicPropertiesName ( ) : array { $ reflectionClass = new \ ReflectionClass ( $ this ) ; $ publicProperties = $ reflectionClass -> getProperties ( \ ReflectionProperty :: IS_PUBLIC ) ; return array_map ( function ( \ ReflectionProperty $ property ) { return $ property -> name ; } , $ publicProper... | Get all the public properties name . |
54,179 | public static function __instance ( ) { if ( empty ( self :: $ __instance ) ) { self :: $ __instance = with ( new \ ReflectionClass ( self :: $ __class ) ) -> newInstanceArgs ( self :: $ __args ) ; } return self :: $ __instance ; } | Get the underlying instance . |
54,180 | public function filterByDataType ( $ data_type ) { $ callback = function ( BindingInterface $ binding , $ key ) use ( $ data_type ) { switch ( $ data_type ) { case PDO :: PARAM_BOOL : return $ binding -> isBoolean ( ) ; case PDO :: PARAM_NULL : return $ binding -> isNull ( ) ; case PDO :: PARAM_INT : return $ binding -... | Create a new collection with only bindings with a given data type . |
54,181 | public function filterByParameter ( $ parameter ) { $ callback = function ( BindingInterface $ binding , $ key ) use ( $ parameter ) { return $ binding -> getParameter ( ) == $ parameter ; } ; return $ this -> filter ( $ callback ) ; } | Create a new collection with only bindings with a parameter that matches the provided parameter value . |
54,182 | public function filterByValue ( $ value ) { $ callback = function ( BindingInterface $ binding , $ key ) use ( $ value ) { return $ binding -> getValue ( ) == $ value ; } ; return $ this -> filter ( $ callback ) ; } | Create a new collection with only bindings with a value that matches the provided value . |
54,183 | public function filterByValueLike ( $ value ) { $ callback = function ( BindingInterface $ binding , $ key ) use ( $ value ) { return strpos ( $ binding -> getValue ( ) , $ value ) !== false ; } ; return $ this -> filter ( $ callback ) ; } | Create a new collection with only bindings with a value that contain the provided value . |
54,184 | public function hydrateFromArray ( array $ array ) { $ this -> clear ( ) ; if ( current ( array_keys ( $ array ) ) === 0 ) { $ array = array_combine ( range ( 1 , count ( $ array ) ) , array_values ( $ array ) ) ; } foreach ( $ array as $ key => $ value ) { $ this -> push ( $ this -> wye -> makeBinding ( $ key , $ valu... | Rebuilds the contents of the collection based on the provided array . Keys become binding parameters and values are used for binding values . 0 - indexed numerical - keyed arrays are shifted once to begin with 1 . |
54,185 | public static function formatPermissions ( array $ userPermissions ) : array { $ userPermissions = self :: format ( $ userPermissions ) ; foreach ( $ userPermissions as $ key => $ permission ) { $ userPermissions [ $ key ] = self :: $ permissions [ $ key ] ; } return $ userPermissions ; } | Replace user permission with PermissionRegistrar |
54,186 | public function index ( $ id , $ code = null ) { $ locale = is_null ( $ code ) ? app ( ) -> getLocale ( ) : $ code ; $ locale = $ locale == null ? 'en' : $ locale ; $ current = Languages :: where ( 'code' , $ locale ) -> first ( ) ; $ languages = Languages :: query ( ) -> get ( ) ; if ( ! $ this -> translationRepositor... | default translation action |
54,187 | public function translation ( $ type ) { $ keys = Input :: get ( 'keys' ) ; $ code = Input :: get ( 'code' ) ; $ collection = Translation :: where ( 'area' , $ type ) -> whereIn ( 'key' , $ keys ) -> where ( 'locale' , $ code ) -> get ( ) ; $ map = array_map ( function ( $ item ) { return array_only ( $ item , [ 'id' ,... | single term translation |
54,188 | public function update ( TranslationListener $ listener , $ type ) { $ params = Input :: all ( ) ; $ first = head ( array_keys ( array_get ( $ params , 'name' ) ) ) ; $ translation = Translation :: whereId ( $ first ) -> with ( 'language' ) -> first ( ) ; $ code = $ translation -> language -> code ; if ( $ this -> tran... | updates term translation |
54,189 | public function group ( TranslationListener $ listener , $ typeId , $ group , $ code = null ) { try { Session :: put ( 'group' , $ group ) ; return redirect ( handles ( "antares::translations/index/{$typeId}/{$code}" ) ) ; } catch ( Exception $ e ) { Log :: warning ( $ e ) ; return $ listener -> groupFailedFailed ( $ e... | process changing translation group |
54,190 | public function rawDispatch ( $ command = null , array $ source = null ) { if ( $ command !== null ) ; elseif ( isset ( $ _REQUEST [ $ this -> cmdVar ] ) ) $ command = $ _REQUEST [ $ this -> cmdVar ] ; else throw new Exception ( 'No command specified!' ) ; if ( ! isset ( $ this -> actions [ $ command ] ) ) throw new Ex... | Executes an API function possibly throwing an exception on errors . |
54,191 | protected function exceptionToResult ( \ Exception $ e ) { if ( ! $ this -> showerror ) return null ; elseif ( $ this -> showtrace ) return array ( 'error' => $ e -> getMessage ( ) , 'trace' => errorTrace ( $ e ) ) ; else return array ( 'error' => $ e -> getMessage ( ) ) ; } | Converts an exception to result data suitable for output as JSON . |
54,192 | public function run ( ) { if ( ! isset ( $ _REQUEST [ $ this -> cmdVar ] ) ) throw new Exception ( 'No task specified.' ) ; elseif ( ! in_array ( $ _REQUEST [ $ this -> cmdVar ] , $ this -> auth_exceptions ) && ! $ this -> auth ( ) ) throw new Exception ( 'Authentication required.' ) ; $ this -> runJSON ( ) ; } | Only runs a function if a valid authentication token has been sent . |
54,193 | public function authCookieToken ( $ strCookieToken ) { if ( $ username = self :: validateCookieToken ( $ strCookieToken ) ) { self :: setUserSession ( array ( 'username' => $ user ) ) ; return true ; } return false ; } | Authenticates a user by using the session cookie |
54,194 | static public function openResult ( $ res ) { if ( ! is_array ( $ res ) ) throw new Exception ( 'Invalid datatype. Array expected!' ) ; if ( isset ( $ res [ 'error' ] ) ) throw new Exception ( 'Server error: ' . $ res [ 'error' ] ) ; if ( ! isset ( $ res [ 'result' ] ) ) throw new Exception ( 'Server returned no result... | Opens the response envelope |
54,195 | public function setUserSession ( $ user ) { if ( ! isset ( $ user [ $ this -> usernameKey ] ) || $ user [ $ this -> usernameKey ] == '' ) throw new Exception ( 'Invalid username' ) ; foreach ( $ user as $ strKey => $ strValue ) $ _SESSION [ 'user_' . $ strKey ] = $ strValue ; } | Sets the user session information |
54,196 | public function getUserSession ( ) { if ( isset ( $ _SESSION [ 'user_' . $ this -> usernameKey ] ) ) { $ arrUser = array ( ) ; foreach ( $ _SESSION as $ strKey => $ strValue ) if ( substr ( $ strKey , 0 , 4 ) == 'user_' ) $ arrUser [ substr ( $ strKey , 4 ) ] = $ strValue ; return $ arrUser ; } return false ; } | Returns the current user session |
54,197 | public function rollback ( ) { if ( $ this -> readOnly ) { return false ; } $ this -> readOnly = true ; fclose ( $ this -> fp ) ; unlink ( $ this -> tmp ) ; } | Closes the temporary file delete it and flags the object as read only . |
54,198 | public function commit ( ) { if ( $ this -> readOnly ) { return false ; } $ this -> readOnly = true ; fflush ( $ this -> fp ) ; fclose ( $ this -> fp ) ; if ( ! @ rename ( $ this -> tmp , $ this -> file ) ) { throw new RuntimeException ( "Cannot move the temporary file" ) ; } return $ this -> file ; } | Finishes the writing of the file and saves it . After this function the object is pretty much read only . |
54,199 | public function write_log ( $ msg = '' , $ log_level = 0 ) { if ( $ this -> log_level > ( int ) $ log_level ) return true ; try { if ( ! $ this -> file -> open ( ( string ) "$this->_log_path/$this->_file_name" ) && ! $ this -> file -> create_file ( "$this->_log_path/$this->_file_name" ) ) { throw new LogException ( ( s... | write to the log file |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.