idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
240,900 | public function set ( $ key , $ value = null ) { i \ type_check ( $ key , [ 'array' , 'string' ] ) ; if ( func_num_args ( ) === 1 && is_string ( $ key ) ) { throw new BadMethodCallException ( sprintf ( "Too few arguments to method %s::%s(). If first argument is a string, a second argument is required" , __CLASS__ , __F... | Set a value or multiple values . |
240,901 | public function aria ( String $ type , String $ element ) { $ this -> settings [ 'attr' ] [ 'aria-' . $ type ] = $ element ; return $ this ; } | Sets aria attribute |
240,902 | public function data ( String $ type , String $ element ) { $ this -> settings [ 'attr' ] [ 'data-' . $ type ] = $ element ; return $ this ; } | Sets data attribute |
240,903 | public function spry ( String $ type , String $ element ) { $ this -> settings [ 'attr' ] [ 'spry-' . $ type ] = $ element ; return $ this ; } | Sets spry attribute |
240,904 | public static function getSuccessDatum ( $ meta = [ ] , $ data = null , $ html = false ) { $ defaultMeta = array ( 'result' => OperationResult :: SUCCESS , 'type' => OperationResult :: getType ( OperationResult :: SUCCESS ) , 'time' => date ( 'Y-m-d H:i:s' ) , 'message' => Yii :: t ( 'cza' , 'Operation completed.' ) ) ... | standardize the datum format |
240,905 | public function getItems ( ) { $ statement = ( null !== $ this -> c && null !== $ this -> d ) ? $ this -> getStatementDay ( ) : $ this -> getStatementPagination ( ) ; $ result = $ statement -> execute ( ( is_array ( $ this -> select ) ) ? $ this -> select [ 1 ] : null ) ; $ resultSet = clone $ this -> resultSetPrototyp... | Returns an ResultSet of items for a page . |
240,906 | public function getStatementDay ( ) { if ( null === $ this -> n ) { $ this -> n = 1 ; } $ date = new \ DateTime ( $ this -> d , new \ DateTimeZone ( 'UTC' ) ) ; $ date -> sub ( new \ DateInterval ( sprintf ( 'P%dD' , ( $ this -> p * $ this -> n ) - 1 ) ) ) ; $ start_date = $ date -> format ( 'Y-m-j' ) ; $ date -> add (... | Get Statement Pagination By Date |
240,907 | public function getTotalItemCount ( ) { if ( $ this -> rowCount !== null ) { return $ this -> rowCount ; } $ param = null ; if ( is_array ( $ this -> select ) ) { $ select = $ this -> select [ 0 ] ; $ param = $ this -> select [ 1 ] ; $ adt = $ this -> sql -> getAdapter ( ) ; $ statement = $ adt -> query ( sprintf ( "SE... | Returns the total number of rows in the result set |
240,908 | private function checkColumns ( $ ok , $ table , $ cols ) { $ fords = false ; foreach ( $ cols as $ ck => $ cv ) { if ( $ cv instanceof Expression || $ cv instanceof Select || is_string ( $ cv ) ) { if ( $ ok === $ ck ) { $ fords = $ ok ; break ; } elseif ( ( $ cv instanceof Expression && $ ok === $ cv -> getExpression... | Check Column name |
240,909 | static function make ( $ mime , $ param = null , $ paramValue = null ) { if ( null === $ param || null === $ paramValue ) { return $ mime ; } return "$mime;$param=$paramValue" ; } | USEFUL STATIC METHODS |
240,910 | final protected function addImageSize ( $ name , $ width , $ height , $ crop = false ) { $ this -> getWpBridge ( ) -> addImageSize ( $ name , $ width , $ height , $ crop ) ; } | Register a WP image size . |
240,911 | public function createUrl ( $ params = array ( ) ) { return Yii :: app ( ) -> createUrl ( $ this -> route , CMap :: mergeArray ( $ params , $ this -> evaluateParams ( $ this -> params ) ) ) ; } | Returns the URL for this model . |
240,912 | protected function evaluateParams ( $ params ) { foreach ( $ params as $ name => $ value ) { if ( is_callable ( $ value ) ) $ params [ $ name ] = $ this -> evaluateExpression ( $ value , array ( 'data' => $ this -> owner ) ) ; } return $ params ; } | Evaluates the given params . |
240,913 | public function findAll ( ) { $ a = [ ] ; foreach ( $ this -> parents as $ x => $ r ) { $ a [ $ x ] = $ this -> find ( $ x ) ; } return $ a ; } | Get map of all items - > representative |
240,914 | public function findDistinct ( ) { $ a = [ ] ; foreach ( $ this -> parents as $ x => $ r ) { $ a [ $ this -> find ( $ x ) ] = null ; } return array_keys ( $ a ) ; } | Get a representative for each component . |
240,915 | function loader ( $ loaderName ) { $ loaderName = $ this -> _normalizeLoaderName ( $ loaderName ) ; if ( ! $ this -> hasAttached ( $ loaderName ) ) throw new \ Exception ( sprintf ( 'Loader with name (%s) has not attached.' , $ loaderName ) ) ; return $ this -> _t_loader_aggregate_Names [ $ loaderName ] ; } | Get Loader By Name |
240,916 | function hasAttached ( $ loaderName ) { $ loaderName = $ this -> _normalizeLoaderName ( $ loaderName ) ; return in_array ( $ loaderName , $ this -> listAttached ( ) ) ; } | Has Loader With This Name Attached? |
240,917 | public function encrypt ( $ data ) { $ iv = openssl_random_pseudo_bytes ( $ this -> getSize ( ) ) ; $ value = openssl_encrypt ( serialize ( $ data ) , $ this -> method , $ this -> key , 0 , $ iv ) ; $ mac = $ this -> hash ( $ iv = base64_encode ( $ iv ) , $ value ) ; return base64_encode ( json_encode ( compact ( 'iv' ... | To encrypt data |
240,918 | public function decrypt ( $ data ) { $ json = base64_decode ( $ data ) ; $ data = json_decode ( $ json ) ; if ( $ this -> hashCheck ( $ data -> iv , $ data -> value , $ data -> mac ) ) { $ iv = base64_decode ( $ data -> iv ) ; $ data = openssl_decrypt ( $ data -> value , $ this -> method , $ this -> key , 0 , $ iv ) ; ... | To decrypt data |
240,919 | protected function hashCheck ( $ iv , $ value , $ mac ) { $ salt = Str :: random ( $ this -> keySize ) ; $ mainMac = hash_hmac ( 'sha256' , $ this -> hash ( $ iv , $ value ) , $ salt ) ; $ checkMac = hash_hmac ( 'sha256' , $ mac , $ salt ) ; if ( $ mainMac === $ checkMac ) { return true ; } return false ; } | To check mac |
240,920 | public function process ( PHP_CodeSniffer_File $ phpcsFile , $ stackPtr ) { $ methodProperties = $ phpcsFile -> getMethodProperties ( $ stackPtr ) ; if ( $ methodProperties [ 'scope' ] !== 'public' ) { return ; } parent :: process ( $ phpcsFile , $ stackPtr ) ; } | Ensures only public methods are processed . |
240,921 | protected function checkSpacingAfterParamType ( PHP_CodeSniffer_File $ phpcsFile , $ param , $ maxType , $ spacing = 1 ) { $ spaces = ( $ maxType - strlen ( $ param [ 'type' ] ) + $ spacing ) ; if ( $ param [ 'type_space' ] !== $ spaces ) { $ error = 'Expected %s spaces after parameter type; %s found' ; $ data = array ... | Check the spacing after the type of a parameter . |
240,922 | public function writeString ( $ string ) { fwrite ( $ this -> stream , ' <si><t>' . Utils :: escape ( $ string ) . '</t></si>' . MyWriter :: EOL ) ; return $ this -> id ++ ; } | String MUST already be escaped |
240,923 | public function initDbTable ( $ table = null ) { if ( empty ( $ table ) ) { return false ; } $ initModel = ClassRegistry :: init ( Inflector :: classify ( $ table ) , true ) ; if ( $ initModel === false ) { return false ; } if ( ! method_exists ( $ initModel , 'initDbTable' ) ) { return false ; } $ ds = $ initModel -> ... | Initialization of database table the initial values |
240,924 | public function setCanvasColor ( array $ canvas_color ) : AbstractResize { if ( Helper :: colorIndexValid ( 'r' , $ canvas_color ) === false || Helper :: colorIndexValid ( 'g' , $ canvas_color ) === false || Helper :: colorIndexValid ( 'b' , $ canvas_color ) === false ) { throw new \ InvalidArgumentException ( Helper :... | Set a new canvas color |
240,925 | public function loadImage ( string $ file , string $ path = '' ) : AbstractResize { if ( file_exists ( $ path . $ file ) === true ) { $ this -> source [ 'path' ] = $ path ; $ this -> source [ 'file' ] = $ file ; $ this -> sourceProperties ( ) ; } else { throw new \ Exception ( "File couldn't be found in supplied destin... | Load the image |
240,926 | protected function sourceProperties ( ) { $ properties = Helper :: imageProperties ( $ this -> source [ 'file' ] , $ this -> source [ 'path' ] ) ; if ( $ properties [ 'width' ] !== null ) { $ this -> source [ 'width' ] = $ properties [ 'width' ] ; $ this -> source [ 'height' ] = $ properties [ 'height' ] ; $ this -> so... | Fetch the dimensions of the source image and calculate the aspect ratio . We also check to ensure that the image is being resized down currently we don t support upscaling the image |
240,927 | public function resizeSource ( ) : AbstractResize { if ( $ this -> intermediate [ 'maintain_aspect' ] === true ) { if ( $ this -> source [ 'aspect_ratio' ] > 1.00 ) { $ this -> intermediateSizeLandscape ( ) ; } else { if ( $ this -> source [ 'aspect_ratio' ] === 1.00 ) { $ this -> intermediateSizeSquare ( ) ; } else { ... | Process the request generate the size required for the image along with the canvas spacing |
240,928 | protected function intermediateSizeLandscape ( ) { $ this -> intermediate [ 'width' ] = $ this -> canvas [ 'width' ] ; $ this -> intermediate [ 'height' ] = intval ( round ( $ this -> intermediate [ 'width' ] / $ this -> source [ 'aspect_ratio' ] , 0 ) ) ; if ( $ this -> intermediate [ 'height' ] > $ this -> canvas [ '... | The source image is landscape maintaining aspect ratio calculate the intermediate image height and width |
240,929 | protected function intermediateSizeSquare ( ) { if ( $ this -> canvas [ 'height' ] === $ this -> canvas [ 'width' ] ) { $ this -> intermediate [ 'width' ] = $ this -> canvas [ 'width' ] ; $ this -> intermediate [ 'height' ] = $ this -> canvas [ 'height' ] ; } else { if ( $ this -> canvas [ 'width' ] > $ this -> canvas ... | The source image is landscape fit as appropriate |
240,930 | 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 |
240,931 | 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 |
240,932 | 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 |
240,933 | 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 |
240,934 | 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 |
240,935 | 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 |
240,936 | public function getResourceFromPath ( Route $ route , $ path ) { $ chunks = explode ( "/" , $ path ) ; return $ route -> resourceOffset ? $ chunks [ $ route -> resourceOffset ] : null ; } | Extract the resource identifier from the given path . |
240,937 | 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 . |
240,938 | 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 |
240,939 | 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 |
240,940 | 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 |
240,941 | 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 . |
240,942 | 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 . |
240,943 | 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 . |
240,944 | 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 |
240,945 | 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 |
240,946 | 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 . |
240,947 | 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 |
240,948 | 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 . |
240,949 | public function load ( $ path , $ file ) { $ the_file = $ path . '/' . $ file ; return json_decode ( $ this -> read_file ( $ the_file ) , true ) ; } | Load the file . |
240,950 | 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 |
240,951 | 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 |
240,952 | 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 . |
240,953 | public function Link ( $ action = null ) { return Controller :: join_links ( parent :: Link ( ) , $ this -> config ( ) -> url_segment , $ action ) ; } | Return URL to this RequestHandler |
240,954 | 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 |
240,955 | 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 |
240,956 | 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 |
240,957 | 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 |
240,958 | 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 . |
240,959 | 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 |
240,960 | 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 |
240,961 | 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 |
240,962 | 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 |
240,963 | 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 . |
240,964 | 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 |
240,965 | 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 |
240,966 | 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 |
240,967 | 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 |
240,968 | 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 |
240,969 | 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 |
240,970 | 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 |
240,971 | 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 |
240,972 | 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 |
240,973 | 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 |
240,974 | 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 |
240,975 | 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 |
240,976 | 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 |
240,977 | 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 |
240,978 | 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 |
240,979 | 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 |
240,980 | 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 |
240,981 | 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 |
240,982 | 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 |
240,983 | 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 |
240,984 | 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 |
240,985 | 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 |
240,986 | 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 |
240,987 | 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 |
240,988 | 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 |
240,989 | 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 |
240,990 | 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 |
240,991 | 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 |
240,992 | 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 |
240,993 | 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 . |
240,994 | 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 . |
240,995 | 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 . |
240,996 | 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 . |
240,997 | 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 . |
240,998 | 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 . |
240,999 | 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 . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.