idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
60,000 | protected function intermediateSizePortrait ( ) { $ this -> intermediate [ 'height' ] = $ this -> canvas [ 'height' ] ; $ this -> intermediate [ 'width' ] = intval ( round ( $ this -> intermediate [ 'height' ] * $ this -> source [ 'aspect_ratio' ] , 0 ) ) ; if ( $ this -> intermediate [ 'width' ] > $ this -> canvas [ '... | The source image is portrait maintaining aspect ratio calculate the intermediate image height and width |
60,001 | protected function canvasSpacingX ( ) { $ this -> canvas [ 'spacing' ] [ 'x' ] = 0 ; if ( $ this -> intermediate [ 'width' ] < $ this -> canvas [ 'width' ] ) { $ difference = $ this -> canvas [ 'width' ] - $ this -> intermediate [ 'width' ] ; if ( $ difference % 2 === 0 ) { $ this -> canvas [ 'spacing' ] [ 'x' ] = $ di... | Calculate any required x canvas spacing necessary if the intermediate image will be smaller than the canvas |
60,002 | protected function canvasSpacingY ( ) { $ this -> canvas [ 'spacing' ] [ 'y' ] = 0 ; if ( $ this -> intermediate [ 'height' ] < $ this -> canvas [ 'height' ] ) { $ difference = $ this -> canvas [ 'height' ] - $ this -> intermediate [ 'height' ] ; if ( $ difference % 2 === 0 ) { $ this -> canvas [ 'spacing' ] [ 'y' ] = ... | Calculate any required y canvas spacing necessary if the intermediate image will be smaller than the canvas |
60,003 | protected function createCanvas ( ) { $ this -> canvas [ 'canvas' ] = imagecreatetruecolor ( $ this -> canvas [ 'width' ] , $ this -> canvas [ 'height' ] ) ; if ( $ this -> canvas [ 'canvas' ] === false ) { throw new \ Exception ( Helper :: ERROR_CALL_IMAGECREATETRUECOLOR ) ; } $ fill_color = imagecolorallocate ( $ thi... | Create the canvas and fill with the canvas colour |
60,004 | protected function resampleCopy ( ) { $ result = imagecopyresampled ( $ this -> canvas [ 'canvas' ] , $ this -> intermediate [ 'copy' ] , $ this -> canvas [ 'spacing' ] [ 'x' ] , $ this -> canvas [ 'spacing' ] [ 'y' ] , 0 , 0 , $ this -> intermediate [ 'width' ] , $ this -> intermediate [ 'height' ] , $ this -> source ... | Resample the image copy |
60,005 | public function save ( ) : AbstractResize { if ( $ this -> file === null ) { $ this -> file = str_replace ( $ this -> extension , '-copy' . $ this -> extension , $ this -> source [ 'file' ] ) ; } if ( $ this -> path === null ) { $ this -> path = $ this -> source [ 'path' ] ; } $ this -> saveFile ( ) ; return $ this ; } | Save the new image |
60,006 | public function getResourceFromPath ( Route $ route , $ path ) { $ chunks = explode ( "/" , $ path ) ; return $ route -> resourceOffset ? $ chunks [ $ route -> resourceOffset ] : null ; } | Extract the resource identifier from the given path . |
60,007 | public function trimPath ( $ path ) { $ path = preg_replace ( "/^\/\//" , "/" , $ path ) ; if ( preg_match ( "/\/{2,}/" , $ path ) ) { throw new \ Exception ( 'Route path has invalid format ' . $ path ) ; } return trim ( $ path , " \t\n\r\0\x0B/" ) ; } | Right and left trim route from blanks and undesired characters . |
60,008 | public static function factory ( array $ config ) { if ( ! array_key_exists ( 'apiKey' , $ config ) ) { throw new \ Exception ( 'Api factory requires $apiKey parameter.' ) ; } $ client = new Client ( [ 'defaults' => [ 'headers' => [ 'X-ApiKey' => $ config [ 'apiKey' ] , ] , ] , ] , [ ] , $ config ) ; $ description = se... | Creates and returns an Api client instance |
60,009 | private static function getDescriptionFromConfig ( array $ config ) { $ data = isset ( $ config [ 'descriptionPath' ] ) && is_readable ( $ config [ 'descriptionPath' ] ) ? include $ config [ 'descriptionPath' ] : include __DIR__ . '/receiptful-api.php' ; return new Description ( $ data ) ; } | Loads the api service description |
60,010 | protected static function getBaseUrl ( ) { $ baseUrl = 'https://' ; if ( ! self :: $ ssl ) { $ baseUrl = 'http://' ; } $ baseUrl .= sprintf ( '%s:%s/%s/' , self :: $ host , self :: $ port , self :: $ context ) ; return $ baseUrl ; } | Construit l url de connexion au serveur |
60,011 | public function run ( $ method , $ parameters ) { dieDump ( $ method ) ; fwrite ( $ this -> connect ( ) , $ this -> command ( $ method , ( array ) $ parameters ) ) ; $ response = trim ( fgets ( $ this -> connect ( ) ) ) ; return $ this -> parse ( $ response ) ; } | Execute a command against the Redis database . |
60,012 | protected function parse ( $ response ) { switch ( substr ( $ response , 0 , 1 ) ) { case '-' : throw new Exception ( 'Redis error: ' . substr ( trim ( $ response ) , 4 ) ) ; case '+' : case ':' : return $ this -> inline ( $ response ) ; case '$' : return $ this -> bulk ( $ response ) ; case '*' : return $ this -> mult... | Parse and return the response from the Redis database . |
60,013 | public function getCombatLevel ( $ includeSummoning = true ) : int { $ attackLevel = $ this -> getSkill ( Skill :: SKILL_ATTACK ) ? $ this -> getSkill ( Skill :: SKILL_ATTACK ) -> getLevel ( ) : 1 ; $ defenceLevel = $ this -> getSkill ( Skill :: SKILL_DEFENCE ) ? $ this -> getSkill ( Skill :: SKILL_DEFENCE ) -> getLeve... | Returns the combat level of this high score . |
60,014 | public function create_thumbnail ( $ width = 200 , $ height = 200 , $ bestfit = false , $ fill = false ) { if ( empty ( $ this -> imagemagik ) || empty ( $ this -> filename ) ) return false ; try { $ this -> imagemagik -> thumbnailimage ( $ width , $ height , $ bestfit , $ fill ) ; } catch ( \ ImagickException $ e ) { ... | Wrapper for Imagick thumbnail |
60,015 | public function saveThumb ( $ path = '' , $ filename = '' ) { if ( empty ( $ this -> filename ) ) return false ; try { $ save_name = ( empty ( $ path ) ? $ this -> path : $ path ) ; $ save_name = "$save_name/" . ( empty ( $ filename ) ? 'th_' . $ this -> filename : $ filename ) ; $ this -> imagemagik -> writeImage ( $ ... | saves the file and opens the fileinfo for this file |
60,016 | public function overwriteAction ( $ anId , Request $ aRequest , FileCommandBus $ aCommandBus , $ aProperty ) { if ( false === $ aRequest -> files -> has ( $ aProperty ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Given %s property is not in the request' , $ aProperty ) ) ; } $ uploadedFile = $ aRequest -> fil... | Overwrite action . |
60,017 | static function convertToResource ( StreamInterface $ stream ) { $ self = new self ; if ( ! RegistryOfWrapperStream :: isRegistered ( $ self -> getLabel ( ) ) ) RegistryOfWrapperStream :: register ( $ self ) ; $ mode = new AccessMode ( ) ; ( ! $ stream -> isWritable ( ) ) ? : $ mode -> openForWrite ( ) ; ( ! $ stream -... | Convert StreamInterface To PHP resource |
60,018 | private function read_file ( $ file ) { $ handler = fopen ( $ file , "r" ) ; $ file_content = fread ( $ handler , filesize ( $ file ) ) ; fclose ( $ handler ) ; return $ file_content ; } | Creates the handler and reads the files . |
60,019 | public function load ( $ path , $ file ) { $ the_file = $ path . '/' . $ file ; return json_decode ( $ this -> read_file ( $ the_file ) , true ) ; } | Load the file . |
60,020 | public function initDefaults ( ) { $ module = Yii :: $ app -> controller -> module ; $ iconTypeAttribute = null ; extract ( $ module -> dataStructure ) ; $ this -> setDefault ( $ iconTypeAttribute , TreeView :: ICON_CSS ) ; foreach ( static :: $ boolAttribs as $ attr ) { $ val = in_array ( $ attr , static :: $ falseAtt... | Initialize default values |
60,021 | public function removeNode ( $ softDelete = true , $ currNode = true ) { if ( $ softDelete ) { $ this -> nodeRemovalErrors = [ ] ; $ module = Yii :: $ app -> controller -> module ; extract ( $ module -> treeStructure ) ; extract ( $ module -> dataStructure ) ; if ( $ this -> isRemovableAll ( ) ) { $ children = $ this -... | Removes a node |
60,022 | public function getBreadcrumbs ( $ depth = 1 , $ glue = ' » ' , $ currCss = 'kv-crumb-active' , $ new = 'Untitled' ) { if ( $ this -> isNewRecord || empty ( $ this ) ) { return $ currCss ? Html :: tag ( 'span' , $ new , [ 'class' => $ currCss ] ) : $ new ; } $ depth = empty ( $ depth ) ? null : intval ( $ depth )... | Generate and return the breadcrumbs for the node . |
60,023 | public function Link ( $ action = null ) { return Controller :: join_links ( parent :: Link ( ) , $ this -> config ( ) -> url_segment , $ action ) ; } | Return URL to this RequestHandler |
60,024 | public function set ( array $ strs ) { if ( ! empty ( $ strs ) ) { foreach ( $ strs as $ _str ) { $ this -> add ( $ _str ) ; } } return $ this ; } | Set a strings stack to build page header title |
60,025 | protected function injectDebugBar ( $ output ) { if ( ! ( $ debugBarConfig = Lb :: app ( ) -> getConfigByName ( 'debugbar' ) ) ) { return $ output ; } if ( empty ( $ debugBarConfig [ 'enabled' ] ) ) { return $ output ; } if ( empty ( $ debugBarConfig [ 'baseUrl' ] ) ) { return $ output ; } if ( empty ( $ debugBarConfig... | Inject debug bar to html output |
60,026 | public function send ( ConversionInterface $ conversion ) : ResponseInterface { foreach ( $ this -> services as $ service ) { if ( is_null ( $ service -> getConfig ( ) ) ) { $ config = $ this -> config -> getConfiguredConfigInstance ( $ service ) ; if ( $ config instanceof PostbackServiceConfigInterface ) { $ service -... | Try each service to send conversion while getting UnsupportedConversionException |
60,027 | private function createGroups ( OutputInterface $ output ) { $ em = $ this -> container -> get ( 'ekyna_user.group.manager' ) ; $ repository = $ this -> container -> get ( 'ekyna_user.group.repository' ) ; foreach ( $ this -> defaultGroups as $ name => $ options ) { $ output -> write ( sprintf ( '- <comment>%s</comment... | Creates default groups entities |
60,028 | private function createSuperAdmin ( Command $ command , OutputInterface $ output ) { $ groupRepository = $ this -> container -> get ( 'ekyna_user.group.repository' ) ; $ userRepository = $ this -> container -> get ( 'ekyna_user.user.repository' ) ; if ( null === $ group = $ groupRepository -> findOneBy ( [ 'name' => ar... | Creates the super admin user . |
60,029 | protected function createAnnotationObjects ( array $ annotations ) { $ objects = array ( ) ; foreach ( $ annotations as $ name => $ args ) { $ name = ucfirst ( $ name ) ; $ class = $ this -> defaultNamespace . $ name . 'Annotation' ; if ( in_array ( strtolower ( $ name ) , self :: getExcludeAnnotationList ( ) ) ) { con... | Create annotations object |
60,030 | protected function convertAnnotationObj ( $ reflection ) { $ annotations = ( array ) $ reflection -> getAnnotations ( ) ; $ result = array ( ) ; foreach ( $ annotations as $ annotation ) { if ( ! array_key_exists ( $ annotation [ 'method' ] , $ result ) ) { $ result [ $ annotation [ 'method' ] ] = array ( ) ; } foreach... | This method converts Notoj returned array to reader data |
60,031 | public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ config = $ serviceLocator -> get ( 'Config' ) ; $ config = empty ( $ config [ 'valu_so' ] ) ? [ ] : $ config [ 'valu_so' ] ; $ annotationBuilder = new AnnotationBuilder ( ) ; if ( ! empty ( $ config [ 'annotations' ] ) ) { $ parser = new Par... | Create an annotation builder for service broker |
60,032 | public function is_valid ( ) { $ ret = false ; if ( is_null ( $ this -> division ) === false && is_null ( $ this -> datafileURI ) === false && is_null ( $ this -> subscribe ) === false && is_null ( $ this -> profileUpdate ) === false && is_null ( $ this -> listLoadName ) === false && is_null ( $ this -> loadMode ) === ... | Validates a listload |
60,033 | public function resolve ( ) { $ this -> file = ( new $ this -> fileClass ( ) ) -> setName ( $ this -> physicalFile -> getBasename ( ) ) -> setOriginalName ( $ this -> originalName ? : $ this -> physicalFile -> getBasename ( ) ) -> setStorePath ( str_replace ( realpath ( $ this -> storePath ) , '' , str_replace ( $ this... | File creation method . |
60,034 | public static function parseAccept ( string $ accept ) { $ result = [ ] ; foreach ( explode ( ',' , $ accept ) as $ directive ) { $ parts = explode ( ';' , $ directive , 2 ) ; $ type = trim ( $ parts [ 0 ] ) ; $ priority = ( ( float ) filter_var ( $ parts [ 1 ] ?? 1 , FILTER_SANITIZE_NUMBER_FLOAT , FILTER_FLAG_ALLOW_FR... | Parses Accept header |
60,035 | protected function parseBody ( string $ resource , string $ type , string $ body ) { $ content_type = static :: parseContentType ( $ type ) ; $ mime = $ content_type [ 'mime' ] ?? $ content_type ; if ( ( $ content_type [ 'charset' ] ?? null ) !== null ) { $ body = mb_convert_encoding ( $ body , 'UTF-8' , $ content_type... | Parses request body |
60,036 | public static function parseContentType ( string $ content_type ) { $ directives = array_map ( 'trim' , explode ( ';' , $ content_type ) ) ; $ result = [ 'mime' => array_shift ( $ directives ) ] ; if ( empty ( $ directives ) ) { return $ result [ 'mime' ] ; } foreach ( $ directives as $ directive ) { $ parts = explode ... | Parses a Content - Type header |
60,037 | protected function parseFields ( Resource $ resource ) { $ fields = $ resource -> getFields ( ) ; if ( ! is_array ( $ fields ) ) { $ this -> sendError ( static :: ERROR_UNKNOWN_FIELDS , $ fields ) ; } return $ fields ; } | Parses fields query and validate against a resource |
60,038 | protected function createModel ( Resource $ resource ) { $ model = new $ resource -> model_class ; $ model -> fill ( $ resource -> data ) ; $ result = $ model -> save ( ) ; if ( $ result === true ) { return $ model ; } $ code = ( empty ( $ resource -> data ) || $ result === null ) ? static :: ERROR_INVALID_PAYLOAD : st... | Creates a Model in the Database |
60,039 | protected function deleteModel ( Model $ model , Resource $ resource , string $ route = null ) { if ( $ model -> delete ( ) ) { return ; } $ message = "Resource '" . ( $ route ?? $ resource -> route ) . "' could not be deleted" ; $ this -> sendError ( static :: ERROR_INTERNAL_SERVER , $ message ) ; } | Deletes a Model |
60,040 | protected function updateModel ( Model $ model , Resource $ resource , string $ route = null ) { $ model -> fill ( $ resource -> data ) ; $ result = $ model -> update ( array_keys ( $ resource -> data ) ) ; if ( $ result === true ) { return ; } $ message = "Resource '" . ( $ route ?? $ resource -> route ) . "' could no... | Updates a Model |
60,041 | protected function checkCache ( Response $ response , string $ e_tags , int $ max_age ) { $ result = $ response ; $ cache_method = $ this -> cache_method ; if ( is_callable ( $ cache_method ) ) { $ hash = '"' . $ cache_method ( serialize ( $ response -> body ) ) . '"' ; if ( strpos ( $ e_tags , $ hash ) !== false ) { $... | Checks if Response is modified from Client s cache |
60,042 | protected function checkMissingFields ( Resource $ resource ) { $ missing = array_diff ( $ resource -> model_class :: getRequiredColumns ( ) , array_keys ( $ resource -> data ) ) ; if ( ! empty ( $ missing ) ) { $ message = "Resource '$resource->name' requires the following " . "missing fields: '" . implode ( "', '" , ... | Checks if resource data fulfills the required columns |
60,043 | protected function checkUnknownField ( Resource $ resource , array $ fields ) { $ message = $ resource -> hasFields ( $ fields ) ; if ( $ message !== true ) { $ this -> sendError ( static :: ERROR_UNKNOWN_FIELDS , $ message ) ; } } | Checks if a resource has all fields passed |
60,044 | public static function compareAccept ( string $ accept , array $ available ) { $ result = [ ] ; foreach ( static :: parseAccept ( $ accept ) as $ type => $ priority ) { if ( strpos ( $ type , '*' ) === false ) { if ( in_array ( $ type , $ available ) ) { $ result [ $ type ] = max ( $ result [ $ type ] ?? 0 , $ priority... | Compares content types in an Accept header with a list of available types |
60,045 | protected function countResource ( string $ resource , array $ where = null ) { $ model = $ this -> resources [ $ resource ] [ 'model' ] ; $ database = $ model :: getDatabase ( ) ; return $ database -> count ( $ model :: TABLE , $ where ?? [ ] ) ; } | Counts rows in Resource s table |
60,046 | protected function externalHandler ( Resource $ resource ) { $ handlers = $ this -> resources [ $ resource -> name ] [ 'handlers' ] ?? [ ] ; if ( ! empty ( $ handlers ) ) { if ( $ this -> safe_method ) { $ handlers = $ handlers [ 'GET' ] ?? null ; if ( is_array ( $ handlers ) ) { $ handlers = $ this -> getAvailableType... | Determines external handler for a Resource and executes it |
60,047 | public static function firstHigher ( array $ list , float $ min = null , float $ max = null ) { $ bounded_list = array_merge ( [ $ min ?? 0 , $ max ?? 1 ] , $ list ) ; $ min = min ( $ bounded_list ) ; $ max = max ( $ bounded_list ) ; $ result = null ; $ higher = $ min ; foreach ( $ list as $ key => $ value ) { $ value ... | Returns key for first highest value |
60,048 | protected function getAcceptedResourceType ( string $ resource , string $ accept ) { $ available = array_keys ( $ this -> getAvailableTypes ( $ resource ) ) ; if ( empty ( $ available ) ) { $ this -> sendError ( static :: ERROR_INTERNAL_SERVER , "Resource '$resource' has invalid GET handlers" ) ; } $ accepted = static ... | Determines an accepted Content - Type for a Resource |
60,049 | public static function getAcceptedType ( string $ accept , array $ available ) { $ list = static :: compareAccept ( $ accept , $ available ) ; if ( empty ( $ list ) ) { return array_values ( $ available ) [ 0 ] ; } $ result = static :: firstHigher ( $ list ) ; if ( $ result !== null ) { return $ result ; } $ forbidden ... | Determines an accepted Content - Type from a list |
60,050 | protected function getAllowedMethods ( string $ resource ) { $ cached = $ this -> cache [ 'allowed_methods' ] [ $ resource ] ?? null ; if ( $ cached !== null ) { return $ cached ; } $ resource_data = $ this -> resources [ $ resource ] ?? null ; if ( $ resource_data === null ) { throw new \ DomainException ( "Invalid re... | Returns a list of allowed methods for a resource |
60,051 | protected function getAvailableTypes ( string $ resource ) { $ cached = $ this -> cache [ 'available_types' ] [ $ resource ] ?? null ; if ( $ cached !== null ) { return $ cached ; } $ types = $ this -> resources [ $ resource ] [ 'handlers' ] [ 'GET' ] ?? [ ] ; $ types = ( is_array ( $ types ) ) ? array_filter ( array_r... | Computes GET Resource s content types |
60,052 | protected function getAuthorizedResources ( $ methods = null ) { $ resources = [ ] ; if ( $ this -> auth instanceof Authentication ) { $ allow = ( array ) ( $ methods ?? $ this -> method ) ; $ authorizations = Authorization :: dump ( [ 'user' => $ this -> auth -> id , ] , [ 'resource' , 'methods' , 'filter' , ] ) ; for... | Returns authorized resources for the authenticated user and their filters |
60,053 | protected function getContentLocation ( Model $ model , Resource $ resource ) { $ query = http_build_query ( $ resource -> query ) ; $ content_location = "$this->url/$resource->name/" . $ this -> getPrimaryKey ( $ model ) . ( $ query !== '' ? '?' . $ query : '' ) ; return $ content_location ; } | Returns Content - Location for a Model in a Resource |
60,054 | protected function getForeignRoutes ( Model $ model , array $ filter = null ) { $ routes = [ ] ; $ foreigns = $ model :: FOREIGN_KEYS ; if ( ! empty ( $ filter ) ) { $ foreigns = Utils :: arrayWhitelist ( $ foreigns , $ filter ) ; } foreach ( $ foreigns as $ column => $ fk ) { foreach ( $ this -> resources as $ resourc... | Returns list of routes to Model s Foreigns |
60,055 | protected function headerLink ( array $ routes ) { $ links = [ ] ; foreach ( $ routes as $ rel => $ route ) { $ links [ ] = '<' . $ this -> url . $ route . '>; rel="' . $ rel . '"' ; } return implode ( ', ' , $ links ) ; } | Generates content for Link header |
60,056 | protected function isPublic ( string $ resource , $ methods = null ) { if ( ( $ this -> authentication ?? null ) === null ) { return true ; } $ resource_data = $ this -> resources [ $ resource ] ?? null ; if ( $ resource_data === null ) { return false ; } $ public = $ resource_data [ 'public' ] ?? $ this -> default_pub... | Tells if a resource s method has public access |
60,057 | protected function prepareResponse ( ) { $ response = new Response ; $ response -> method = $ this -> method ; $ response -> zlib_compression = $ this -> zlib_compression ; return $ response ; } | Creates a new Response object with some properties filled |
60,058 | public static function reverseForeignKey ( string $ model_class , Model $ target ) { $ target_class = get_class ( $ target ) ; $ column = null ; $ found = false ; foreach ( $ model_class :: FOREIGN_KEYS as $ column => $ fk ) { if ( $ target_class === $ fk [ 0 ] ) { $ found = true ; break ; } } if ( $ column === null ||... | Finds the Foreign Key for a Model instance from a Model class |
60,059 | public function flush ( ) { if ( ! count ( $ this -> updated ) ) { return ; } foreach ( $ this -> updated as $ lang => $ true ) { $ words = array ( ) ; foreach ( $ this -> words as $ word => $ wordLanguages ) { if ( in_array ( $ lang , $ wordLanguages ) ) { $ words [ ] = $ word ; } } $ file = $ this -> dictionaryDir . ... | Flush updated dictionaries |
60,060 | private function loadDictionaries ( ) { if ( null !== $ this -> words ) { return ; } $ this -> words = array ( ) ; $ dictionaryFiles = glob ( $ this -> dictionaryDir . '/*' ) ; foreach ( $ dictionaryFiles as $ dictionaryFile ) { $ fileName = substr ( $ dictionaryFile , strlen ( $ this -> dictionaryDir ) + 1 ) ; preg_ma... | Load dictionaries from directory |
60,061 | private function actionPasswordReplace ( SymfonyStyle $ helper ) { if ( false === $ helper -> confirm ( 'Are you sure? Only use this for development purposes!' , false ) ) { return null ; } $ userClass = $ this -> getUserEntityClass ( ) ; if ( null === $ userClass ) { throw new \ RuntimeException ( 'User entity not fou... | Password Replace action |
60,062 | private function getUserEntityClass ( ) { foreach ( $ this -> getDoctrine ( ) -> getManager ( ) -> getMetadataFactory ( ) -> getAllMetadata ( ) as $ meta ) { $ reflectionClass = $ meta -> getReflectionClass ( ) ; if ( true === $ this -> hasAbstractParent ( $ reflectionClass , User :: class ) ) { return $ meta -> getNam... | Get User Entity Class |
60,063 | public function parse ( string $ text ) { try { $ result = $ this -> syntax -> parse ( $ text ) ; $ this -> success = true ; } catch ( ParseException $ e ) { $ result = $ this -> default ; $ this -> success = false ; } return $ result ; } | Tries to parse the string using the syntax and return the result . If the parse failed success flag is set to false and the default value is returned . |
60,064 | public function load ( $ basePath ) { $ this -> basePath = $ basePath ; $ this -> renderer = new Renderer ( $ this -> getViewsPath ( ) ) ; return $ this -> loadCustomTables ( ) -> loadPostTypes ( ) -> loadFieldGroups ( ) -> loadAcfJson ( ) -> loadActions ( ) -> loadShortCodes ( ) -> loadOptionScreens ( ) -> loadCliComm... | Load all plugin configuration . |
60,065 | protected function loadCustomTables ( ) { if ( $ config = $ this -> loadConfigFile ( 'tables.php' ) ) { $ app = $ this -> app ; foreach ( $ config as $ installerClass ) { if ( is_string ( $ installerClass ) && is_subclass_of ( $ installerClass , 'Tev\Database\CustomTables\AbstractInstaller' ) ) { register_activation_ho... | Load custom database table installers from configuration files . |
60,066 | protected function loadPostTypes ( ) { if ( $ config = $ this -> loadConfigFile ( 'post_types.php' ) ) { $ callbacks = array ( ) ; foreach ( $ config as $ postTypeName => $ args ) { $ callbacks [ ] = $ cb = function ( ) use ( $ postTypeName , $ args ) { register_post_type ( $ postTypeName , $ args ) ; } ; add_action ( ... | Load custom post types from configuration files . |
60,067 | protected function loadFieldGroups ( ) { if ( function_exists ( 'register_field_group' ) && ( $ config = $ this -> loadConfigFile ( 'field_groups.php' ) ) ) { foreach ( $ config as $ fieldGroupConfig ) { register_field_group ( $ fieldGroupConfig ) ; } } return $ this ; } | Load custom field groups from configuration files . |
60,068 | protected function loadActions ( ) { if ( $ config = $ this -> loadConfigFile ( 'actions.php' ) ) { $ app = $ this -> app ; $ renderer = $ this -> renderer ; foreach ( $ config as $ actionName => $ provider ) { if ( is_string ( $ provider ) && is_subclass_of ( $ provider , 'Tev\Plugin\Action\AbstractProvider' ) ) { $ a... | Load actions from configuration providers . |
60,069 | protected function loadAcfJson ( ) { $ config = $ this -> getConfigPath ( ) . '/acf-json' ; if ( file_exists ( $ config ) ) { add_filter ( 'acf/settings/load_json' , function ( $ paths ) use ( $ config ) { $ paths [ ] = $ config ; return $ paths ; } ) ; } return $ this ; } | Load ACF JSON config if supplied . |
60,070 | protected function loadShortCodes ( ) { if ( $ config = $ this -> loadConfigFile ( 'shortcodes.php' ) ) { $ renderer = $ this -> renderer ; $ app = $ this -> app ; foreach ( $ config as $ shortcode => $ provider ) { add_shortcode ( $ shortcode , function ( $ attrs , $ content ) use ( $ app , $ provider , $ renderer ) {... | Load shortcodes from configuration files . |
60,071 | protected function loadOptionScreens ( ) { if ( function_exists ( 'acf_add_options_page' ) && ( $ config = $ this -> loadConfigFile ( 'option_screens.php' ) ) ) { foreach ( $ config as $ optionScreenConfig ) { acf_add_options_page ( $ optionScreenConfig ) ; } } return $ this ; } | Load custom option screens from configuration files . |
60,072 | protected function loadCliCommands ( ) { if ( defined ( 'WP_CLI' ) && WP_CLI && ( $ config = $ this -> loadConfigFile ( 'commands.php' ) ) ) { foreach ( $ config as $ command => $ className ) { \ WP_CLI :: add_command ( $ command , $ className ) ; } } return $ this ; } | Load custom WP CLI commands from configuration files . |
60,073 | protected function loadConfigFile ( $ file ) { $ path = $ this -> getConfigPath ( ) . '/' . $ file ; if ( file_exists ( $ path ) ) { $ config = include $ path ; return is_array ( $ config ) ? $ config : null ; } return null ; } | Load a config file from the config directory . |
60,074 | public static function isTimestamp ( $ string ) { if ( substr ( $ string , 0 , 5 ) == "/Date" ) { return true ; } try { new DateTime ( '@' . $ string ) ; } catch ( Exception $ e ) { return false ; } return true ; } | Determine if the string is a Unix Timestamp |
60,075 | public function setMaxExternalLastEdited ( array $ apidata ) { $ external_last_edited_key = $ this -> ExternalLastEditedKey ; if ( ! $ external_last_edited_key ) { user_error ( _t ( 'Consumer.ExternalLastEditedKeyNeeded' , 'Property ExternalLastEditedKey needs to be set before calling setMaxExternalLastEdited method' )... | Set the ExternalLastEdited to the maximum last edited date |
60,076 | protected function assignUsersToAssignment ( ) { $ assignment = fp_env ( 'ACACHA_FORGE_ASSIGNMENT' ) ; foreach ( $ this -> users as $ user ) { $ uri = str_replace ( '{assignment}' , $ assignment , config ( 'forge-publish.assign_user_to_assignment_uri' ) ) ; $ uri = str_replace ( '{user}' , $ user , $ uri ) ; $ url = co... | Assign users to assignment |
60,077 | protected function askForUsers ( ) { $ default = 0 ; $ users = $ this -> users ( ) ; $ user_names = array_merge ( [ 'Skip' ] , collect ( $ users ) -> pluck ( 'name' ) -> toArray ( ) ) ; $ selected_user_names = $ this -> choice ( 'Users?' , $ user_names , $ default , null , true ) ; if ( $ selected_user_names == 0 ) ret... | Ask for users . |
60,078 | public static function ipn ( ) { if ( ! count ( $ _POST ) ) { return false ; } if ( Config :: get ( 'paypal.production_mode' ) ) { $ endpoint = 'https://www.paypal.com/cgi-bin/webscr' ; } else { $ endpoint = 'https://www.sandbox.paypal.com/cgi-bin/webscr' ; } $ fields = http_build_query ( array ( 'cmd' => '_notify-vali... | Automatically verify Paypal IPN communications . |
60,079 | public function profile ( $ classname , $ methodname , $ methodargs , $ invocations = 1 ) { if ( class_exists ( $ classname ) != TRUE ) { throw new Exception ( "{$classname} doesn't exist" ) ; } $ method = new ReflectionMethod ( $ classname , $ methodname ) ; $ instance = NULL ; if ( ! $ method -> isStatic ( ) ) { $ cl... | Runs a method with the provided arguments and returns details about how long it took . Works with instance methods and static methods . |
60,080 | public function flush ( ) { if ( ! $ this -> hasConnection ( ) ) { return false ; } try { return $ this -> memcache -> flush ( ) ; } catch ( \ Exception $ e ) { } return false ; } | Flush all existing Cache |
60,081 | public function beforeFilter ( ) { if ( ! isset ( $ this -> _beforeFilters [ $ this -> _action ] ) ) { return false ; } foreach ( $ this -> _beforeFilters [ $ this -> _action ] as $ method ) { call_user_func ( $ method ) ; } } | Executes all the registered beforeFilters for the current action |
60,082 | public function afterFilter ( ) { if ( ! isset ( $ this -> _afterFilters [ $ this -> _action ] ) ) { return false ; } foreach ( $ this -> _afterFilters [ $ this -> _action ] as $ method ) { call_user_func ( $ method ) ; } } | Execute all the registered afterFilters for the current action |
60,083 | public final function getView ( $ id , $ view , & $ properties_cache = null , & $ view_cache = null , & $ persistent_view_cache = null ) { if ( isset ( $ view_cache [ $ view ] ) ) { return $ view_cache [ $ view ] ; } switch ( $ view ) { case 'url' : return $ this -> urlFormat ( $ id , $ this -> url_fmt , $ properties_c... | Get properties in given view . |
60,084 | protected function urlFormat ( $ id , $ url_fmt , $ properties_cache ) : string { if ( isset ( $ url_fmt ) ) { if ( $ properties_cache === null ) { return Utils :: filename_format ( $ url_fmt , array_combine ( $ this -> describeId ( ) , ( array ) $ id ) ) ; } else { return Utils :: filename_format ( $ url_fmt , $ prope... | Create URL using properties and given format . |
60,085 | protected function resolveMachineReference ( string $ reference_name , array $ properties_cache ) : Reference { if ( ! isset ( $ this -> references [ $ reference_name ] ) ) { throw new \ InvalidArgumentException ( 'Unknown reference: ' . $ reference_name ) ; } $ r = $ this -> references [ $ reference_name ] ; $ ref_mac... | Helper function to resolve reference to another machine . |
60,086 | public function isTransitionAllowed ( Reference $ ref , $ transition_name , $ state = null , & $ access_policy = null ) { if ( $ state === null ) { $ state = $ ref -> state ; } if ( $ transition_name == '' ) { $ access_policy = $ this -> read_access_policy ; return $ this -> checkAccessPolicy ( $ this -> read_access_po... | Returns true if transition can be invoked right now . |
60,087 | public function ref ( $ id ) : Reference { $ ref = new $ this -> reference_class ( $ this -> smalldb , $ this , $ id ) ; if ( $ this -> debug_logger ) { $ this -> debug_logger -> afterReferenceCreated ( null , $ ref ) ; } return $ ref ; } | Helper to create Reference to this machine . |
60,088 | public function hotRef ( $ properties ) : Reference { $ ref = $ this -> reference_class :: createPreheatedReference ( $ this -> smalldb , $ this , $ properties ) ; if ( $ this -> debug_logger ) { $ this -> debug_logger -> afterReferenceCreated ( null , $ ref , $ properties ) ; } return $ ref ; } | Create pre - heated reference using properties loaded from elsewhere . |
60,089 | public function performSelfCheck ( ) { $ results = [ ] ; $ results [ 'id' ] = $ this -> describeId ( ) ; $ results [ 'class' ] = get_class ( $ this ) ; $ results [ 'missing_methods' ] = [ ] ; $ results [ 'errors' ] = $ this -> errors ; foreach ( $ this -> describeAllMachineActions ( ) as $ a => $ action ) { foreach ( $... | Perform self - check . |
60,090 | public function findUnreachableStates ( ) : array { $ g = new Graph ( ) ; $ g -> indexNodeAttr ( 'unreachable' ) ; $ g -> createNode ( '' , [ 'unreachable' => false ] ) ; foreach ( $ this -> states as $ s => $ state ) { if ( $ s !== '' ) { $ g -> createNode ( $ s , [ 'unreachable' => true ] ) ; } } foreach ( $ this -> ... | Run DFS from not - exists state and return list of unreachable states . |
60,091 | private function exportDotRenderGroups ( $ groups , $ group_content , $ indent = "\t" ) { foreach ( $ groups as $ g => $ group ) { echo $ indent , "subgraph " , $ this -> exportDotIdentifier ( $ g , 'cluster_' ) , " {\n" ; if ( isset ( $ group [ 'label' ] ) ) { echo $ indent , "\t" , "label = \"" , addcslashes ( $ grou... | Recursively render groups in state machine diagram . |
60,092 | protected function exportDotRenderExtras ( $ debug_opts ) { if ( ! empty ( $ this -> state_diagram_extras ) ) { echo "\tsubgraph cluster_extras {\n" , "\t\tgraph [ margin = 10; ];\n" , "\t\tcolor=transparent;\n\n" ; foreach ( $ this -> state_diagram_extras as $ i => $ e ) { echo "\n\t# Extras " , str_replace ( "\n" , "... | Render extra diagram features . |
60,093 | protected function exportJsonAddExtras ( $ debug_opts , array $ machine_graph ) : array { if ( ! empty ( $ this -> state_diagram_extras_json ) ) { $ graph = $ this -> state_diagram_extras_json ; if ( ! isset ( $ graph [ 'layout' ] ) ) { $ graph [ 'layout' ] = 'row' ; $ graph [ 'layoutOptions' ] = [ 'align' => 'top' , ]... | Add extra diagram features into the diagram . |
60,094 | public function disconnect ( ) : void { if ( $ this -> dbconn -> inTransaction ( ) ) { $ this -> dbconn -> rollBack ( ) ; } $ this -> dbconn = null ; $ this -> is_connected = false ; } | Close the connection if it has been established . |
60,095 | public function beginTransaction ( ) : bool { if ( $ this -> dbconn -> inTransaction ( ) ) { throw new TransactionErrorException ( "A transaction has already been started." ) ; } try { return $ this -> dbconn -> beginTransaction ( ) ; } catch ( \ PDOException $ exception ) { throw new TransactionsNotSupportedException ... | Start a transaction . |
60,096 | public function toArray ( ) : ? array { if ( null === $ this -> stmt || false === $ this -> stmt ) { return null ; } return $ this -> stmt -> toArray ( ) ; } | Gets the results and a multidimensional array . |
60,097 | private static function clearName ( $ string , $ removeWords ) { $ string = str_replace ( ' ' , '-' , $ string ) ; $ string = preg_replace ( '/[^A-Za-z0-9\-]/' , '' , $ string ) ; foreach ( $ removeWords as $ word ) { $ string = str_replace ( $ word , '' , $ string ) ; } $ string = substr ( $ string , 0 , 29 ) ; return... | remove special chars and words from string |
60,098 | public function upload ( $ file = null ) { if ( empty ( $ file ) || ! is_array ( $ file ) ) return false ; $ this -> u_tmp_name = $ file [ 'tmp_name' ] ; $ this -> u_name = $ file [ 'name' ] ; $ this -> u_size = $ file [ 'size' ] ; $ this -> u_mime_type = $ file [ 'type' ] ; $ this -> u_error = isset ( $ file [ 'error'... | current upload process |
60,099 | private function _get_file_extension ( ) { if ( empty ( $ this -> u_mime_type ) ) return false ; $ tmp = explode ( '/' , $ this -> u_mime_type ) ; $ this -> file_extension = array_pop ( $ tmp ) ; unset ( $ tmp ) ; return true ; } | gets the suffix for the file that has been uploaded |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.