idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
54,000 | public static function fromData ( array $ data ) { $ class = get_called_class ( ) ; $ isDynamic = is_a ( $ class , DynamicEntity :: class , true ) ; $ entity = ( new \ ReflectionClass ( $ class ) ) -> newInstanceWithoutConstructor ( ) ; object_set_properties ( $ entity , $ data , $ isDynamic ) ; if ( method_exists ( $ ... | Create an entity from persisted data . |
54,001 | public function markAsPersisted ( ) : void { $ this -> markNew ( false ) ; $ this -> dispatchEvent ( new Event \ Persisted ( $ this ) ) ; } | Mark entity as persisted . |
54,002 | public function validate ( $ page , Constraint $ constraint ) { if ( ! $ page instanceof CreateAction && ! $ page instanceof Page ) { throw new \ InvalidArgumentException ( sprintf ( '%s can only validate %s or %s objects; %s given.' , self :: class , Page :: class , CreateAction :: class , is_object ( $ page ) ? get_c... | Validate given page path is unique . Works with page create action too . |
54,003 | public function unfold ( $ start_value ) { if ( count ( $ this -> contents ( ) ) > 0 ) { throw new \ LogicException ( "Can't unfold into non-empty directory '" . $ this -> path ( ) . "'." ) ; } return new Unfolder ( $ this , $ start_value ) ; } | Get an object that can unfold a directory structure in this directory . |
54,004 | public static final function ana ( \ Closure $ unfolder , $ start_value ) { $ unfolded = $ unfolder ( $ start_value ) ; if ( $ unfolded -> isFile ( ) ) { return $ unfolded ; } return new GenericFixedFDirectory ( $ unfolded -> fmap ( function ( $ value ) use ( $ unfolder ) { return self :: ana ( $ unfolder , $ value ) ;... | As we have an unfix and an underlying fmap from FDirectory we could also implement the anamorphism . |
54,005 | public function dispatch ( array $ events ) { foreach ( $ events as $ event ) { $ eventName = $ this -> getEventName ( $ event ) ; $ this -> app -> fireEvent ( $ eventName , $ event ) ; $ this -> app -> logEvent ( $ eventName . ' was fired.' ) ; } } | Dispatch all events . |
54,006 | public function add ( FormField $ field ) { if ( $ this -> owner -> hasTabSet ( ) ) { $ before = ( $ this -> tab == "Main" && $ this -> owner -> dataFieldByName ( "Content" ) ) ? "Content" : null ; $ this -> owner -> addFieldToTab ( "Root.{$this->tab}" , $ field , $ before ) ; } else { $ this -> owner -> push ( $ field... | Adds a FormField to the FieldList |
54,007 | public function group ( ) { $ group = FieldGroup :: create ( ) ; $ group -> FieldList = $ this -> owner ; $ this -> add ( $ group ) ; return $ group ; } | Adds a FieldGroup to the FieldList |
54,008 | public function allMethodNames ( ) { $ methods = array ( 'add' , 'tab' , 'field' , 'configure' , 'group' , 'hasmanygrid' , 'imageupload' , 'removefield' , 'addfield' ) ; foreach ( SS_ClassLoader :: instance ( ) -> getManifest ( ) -> getDescendantsOf ( "FormField" ) as $ field ) { $ methods [ ] = strtolower ( preg_repla... | Defines all possible methods for this class . Used to support wildcard methods |
54,009 | public function listAction ( Request $ request ) { return $ this -> render ( 'SynapseAdminBundle:Skeleton:list.html.twig' , array ( 'skeletons' => $ this -> container -> get ( 'synapse.template.loader' ) -> retrieveAll ( array ( 'scope' => TemplateInterface :: GLOBAL_SCOPE , ) ) , ) ) ; } | Skeletons listing action . |
54,010 | public function initAction ( Request $ request ) { $ form = $ this -> container -> get ( 'form.factory' ) -> createNamed ( 'skeleton' , GlobalCreationType :: class , null , array ( 'action' => $ this -> container -> get ( 'router' ) -> generate ( 'synapse_admin_skeleton_init' ) , 'method' => 'POST' , 'csrf_protection' ... | Skeleton initialization action . |
54,011 | public function beginSession ( $ callback , array $ scope = [ ] ) { $ requestUrl = $ this -> config [ 'request_url' ] ; if ( 0 < count ( $ scope ) ) { $ requestUrl .= ( ( false === strpos ( $ requestUrl , '?' ) ) ? '?' : '&' ) . 'scope=' . rawurlencode ( implode ( ' ' , $ scope ) ) ; } $ response = $ this -> sendCustom... | Start setting up a new OAuth session . |
54,012 | public function confirmSession ( $ token , $ verifier ) { if ( $ this -> authentication -> getTokenStorage ( ) -> getRequestToken ( ) != $ token ) { throw new LogicException ( 'The request tokens do not match.' ) ; } $ response = $ this -> sendCustomOauthPostRequest ( $ this -> config [ 'access_url' ] , [ 'verifier' =>... | Finish an OAuth session converting the request to access tokens . |
54,013 | protected function convertPathsToNames ( $ tags ) { if ( $ tags ) { $ aliases = array ( ) ; foreach ( $ tags as $ tag ) { if ( ! empty ( $ tag -> path ) ) { if ( $ pathParts = explode ( '/' , $ tag -> path ) ) { $ aliases = array_merge ( $ aliases , $ pathParts ) ; } } } if ( $ aliases ) { $ aliases = array_unique ( $ ... | Function pour convertir des chemins de tags en chemin de noms . |
54,014 | private function doLoadFromDescriptors ( MetadataInterface $ metadata , array $ descriptors ) : void { foreach ( $ descriptors as $ descriptor ) { $ processor = $ this -> processorFactory -> getProcessor ( $ descriptor ) ; if ( null === $ processor ) { continue ; } $ processor -> process ( $ metadata , $ descriptor ) ;... | Call processors . |
54,015 | public final function setX ( float $ x ) : self { $ this -> coordinates [ self :: X ] = $ this -> gf -> getPrecisionModel ( ) -> makePrecise ( $ x ) ; return $ this ; } | Sets the x - coordinate value of this Point . |
54,016 | public function setY ( float $ y ) : self { $ this -> coordinates [ self :: Y ] = $ this -> gf -> getPrecisionModel ( ) -> makePrecise ( $ y ) ; return $ this ; } | Sets the y - coordinate value of this Point . |
54,017 | public function setZ ( float $ z ) : self { if ( ! $ this -> is3D ( ) ) { throw GeometryException :: coordinateNotSupported ( 'z' ) ; } $ this -> coordinates [ self :: Z ] = $ this -> gf -> getPrecisionModel ( ) -> makePrecise ( $ z ) ; return $ this ; } | Sets the z - coordinate value of this Point . |
54,018 | public function setM ( float $ m ) : self { if ( ! $ this -> isMeasured ( ) ) { throw GeometryException :: coordinateNotSupported ( 'm' ) ; } $ this -> coordinates [ self :: M ] = $ this -> gf -> getPrecisionModel ( ) -> makePrecise ( $ m ) ; return $ this ; } | Sets the m - coordinate value of this Point . |
54,019 | public function isEmpty ( ) : bool { foreach ( $ this -> coordinates as $ value ) { if ( is_nan ( $ value ) ) { return true ; } } return false ; } | Indicates whether this Point is empty . |
54,020 | protected function event ( $ name , $ type , $ object , $ event ) { if ( is_null ( $ this -> triggers ) ) { return ; } $ event = ucfirst ( $ event ) ; $ deprecatedEvent = strtolower ( $ event ) ; if ( method_exists ( $ this -> triggers , "{$name}{$event}" ) ) { call_user_func ( array ( $ this -> triggers , "{$name}{$ev... | Calls trigger events |
54,021 | public function delete ( string $ key ) : bool { $ file = $ this -> cacheFile ( $ key ) ; if ( is_file ( $ file ) ) { return unlink ( $ file ) ; } return false ; } | Delete from cache |
54,022 | protected function fileWrite ( string $ file , string $ data ) : bool { $ fh = fopen ( $ file , 'c' ) ; flock ( $ fh , LOCK_EX ) ; chmod ( $ file , 0774 ) ; ftruncate ( $ fh , 0 ) ; fwrite ( $ fh , $ data ) ; flock ( $ fh , LOCK_UN ) ; fclose ( $ fh ) ; return true ; } | Write on file |
54,023 | public function deleteAction ( $ zoneId , $ componentId , Request $ request ) { if ( ! $ zone = $ this -> container -> get ( 'synapse.zone.loader' ) -> retrieve ( $ zoneId ) ) { throw new NotFoundHttpException ( sprintf ( 'No zone found under id "%s"' , $ zoneId ) ) ; } if ( ! $ component = $ this -> container -> get (... | Component deletion action . |
54,024 | public function beforeTraverse ( array $ nodes ) { $ keyedNodes = [ ] ; foreach ( $ nodes as $ node ) { $ hashFunc = $ node -> getType ( ) . 'Hash' ; if ( ! method_exists ( $ this , $ hashFunc ) ) { $ keyedNodes [ ] = $ node ; continue ; } $ keyedNodes [ $ this -> $ hashFunc ( $ node ) ] = $ node ; } return $ keyedNode... | Turn numbers into unique string . |
54,025 | public function getBySession ( SessionEntity $ session ) { foreach ( $ this -> getDbConnection ( ) -> fetchAll ( 'SELECT oc.id, oc.name FROM oauth_client oc INNER JOIN oauth_session os ON(oc.id = os.client_id) WHERE os.id = :id' , [ 'id' => $ session -> getId ( ) ] ) as $ row ) { if ( $ row ) { re... | Get the client associated with a session |
54,026 | public function escapeHtmlAttrCallback ( $ matches ) { static $ entityMap = array ( 34 => 'quot' , 38 => 'amp' , 60 => 'lt' , 62 => 'gt' , ) ; $ chr = $ matches [ 0 ] ; $ ord = ord ( $ chr ) ; if ( ( $ ord <= 0x1f && $ chr != "\t" && $ chr != "\n" && $ chr != "\r" ) || ( $ ord >= 0x7f && $ ord <= 0x9f ) ) { return '&#x... | This function is adapted from code coming from Zend Framework . |
54,027 | protected function validateSchema ( \ DOMDocument $ dom ) { try { $ valid = $ dom -> schemaValidate ( $ this -> schema ) ; return $ valid ; } catch ( \ Exception $ e ) { } throw new InvalidConfigurationSchema ( 'Schema is not valid' ) ; } | validate the xsd schema |
54,028 | public function load ( $ default = null ) { if ( file_exists ( $ this -> xmlfile ) ) { if ( ! $ this -> cache -> isNew ( $ this -> xmlfile ) ) { return $ this -> cache -> get ( ) ; } $ data = $ this -> parse ( ) ; $ this -> cache -> write ( $ data ) ; return $ data ; } return $ default ; } | load the xml configuration . |
54,029 | protected function getSimpleXmlObject ( ) { $ dom = new \ DOMDocument ; $ dom -> load ( $ this -> xmlfile ) ; if ( $ this -> validateSchema ( $ dom ) ) { return simplexml_import_dom ( $ dom , $ this -> simplexmlclass ) ; } } | get the SimpleXmlObject |
54,030 | public function setSimpleXmlClass ( $ simplexmlclass ) { $ interfaces = class_implements ( $ simplexmlclass ) ; $ interface = sprintf ( '%s\%s' , __NAMESPACE__ , 'SimpleXmlConfigInterface' ) ; if ( ! in_array ( $ interface , $ interfaces ) ) { throw new \ InvalidArgumentException ( sprintf ( 'SimpleXml class must imple... | set the SimpleXml class |
54,031 | public function getData ( ) { $ data = GuzzleHttp \ json_decode ( $ this -> response -> getBody ( ) , true ) ; if ( ! isset ( $ data [ "result" ] ) ) { throw new EndpointException ( "Invalid result structure: " . $ this -> response -> getBody ( ) ) ; } $ this -> checkStatus ( $ data [ "result" ] ) ; return $ data ; } | Gets JSON data as array |
54,032 | private function checkStatus ( $ expectedStatus ) { $ status = $ this -> response -> getStatusCode ( ) ; if ( $ status != $ expectedStatus ) { throw new EndpointException ( "Unexpected HTTP status {$status} " . $ this -> response -> getReasonPhrase ( ) ) ; } } | Checks HTTP status |
54,033 | public static function getByName ( $ name ) { $ name = ( string ) $ name ; $ class = get_called_class ( ) ; if ( isset ( self :: $ instances [ $ class ] [ $ name ] ) ) { return self :: $ instances [ $ class ] [ $ name ] ; } $ const = $ class . '::' . $ name ; if ( ! defined ( $ const ) ) { throw new \ InvalidArgumentEx... | Get an enumerator instance by the constant name |
54,034 | public static function getByValue ( $ value ) { $ class = get_called_class ( ) ; $ constants = array_flip ( static :: getConstants ( ) ) ; if ( isset ( $ constants [ $ value ] ) ) { return self :: $ instances [ $ class ] [ $ constants [ $ value ] ] = new $ class ( $ value ) ; } else { throw new \ InvalidArgumentExcepti... | Get an enumerator instance by the constant value |
54,035 | public static function has ( $ value ) { if ( $ value instanceof static && get_class ( $ value ) === get_called_class ( ) ) { return true ; } $ class = get_called_class ( ) ; $ constants = static :: detectConstants ( $ class ) ; return in_array ( $ value , $ constants , true ) ; } | Is the given value part of this enumeration |
54,036 | private static function detectConstants ( $ class ) { if ( ! isset ( self :: $ constants [ $ class ] ) ) { $ reflection = new \ ReflectionClass ( $ class ) ; $ constants = $ reflection -> getConstants ( ) ; $ notUnique = [ ] ; foreach ( $ constants as $ value ) { $ names = array_keys ( $ constants , $ value , true ) ; ... | Detect all available constants by the given class |
54,037 | protected function matchUAAgainstKey ( $ key , $ userAgent = null ) { $ key = Inflector :: lower ( $ key ) ; $ _rules = array_change_key_case ( $ this -> getRules ( ) ) ; if ( Arrays :: exists ( $ key , $ _rules ) ) { if ( empty ( $ _rules [ $ key ] ) ) { return null ; } return $ this -> match ( $ _rules [ $ key ] , $ ... | Search for a certain key in the rules array . If the key is found the try to match the corresponding regex agains the User - Agent . |
54,038 | public function isMobile ( $ userAgent = null , $ httpHeaders = null ) { if ( $ httpHeaders ) { $ this -> setHttpHeaders ( $ httpHeaders ) ; } if ( $ userAgent ) { $ this -> setUserAgent ( $ userAgent ) ; } $ this -> setDetectionType ( self :: DETECTION_TYPE_MOBILE ) ; if ( $ this -> checkHttpHeadersForMobile ( ) ) { r... | Check if the device is mobile . Returns true if any type of mobile device detected including special ones |
54,039 | public function convert ( AccessInterface $ object , $ field , $ value , $ conversion ) { $ type = $ this -> getFieldType ( $ object , $ field ) ; if ( isset ( $ this -> filters [ $ type ] ) ) { if ( $ conversion == self :: SETTER ) { $ value = $ this -> filters [ $ type ] -> convertToSetterValue ( $ this , $ object , ... | Convert a value |
54,040 | public function fill ( AccessInterface $ object , $ data = array ( ) , $ files = array ( ) ) { $ data = array_replace_recursive ( $ files , $ data ) ; $ allowed = $ object -> loadFillableFields ( $ this ) ; foreach ( $ data as $ name => $ value ) { if ( in_array ( $ name , $ allowed ) ) { $ this -> set ( $ object , $ n... | Set all fields of an object with the supplied data |
54,041 | public function getFieldType ( $ object , $ field ) { $ metadata = $ this -> manager -> getClassMetadata ( get_class ( $ object ) ) ; if ( $ metadata -> hasField ( $ field ) ) { return $ metadata -> getTypeOfField ( $ field ) ; } else if ( $ metadata -> hasAssociation ( $ field ) && $ metadata -> isSingleValuedAssociat... | Gets the type of a field . Treats associations as types . |
54,042 | static function set ( ) { $ info = debug_backtrace ( ) ; self :: $ data [ ] = [ 'time' => time ( ) , 'microtime' => microtime ( true ) , 'text' => ( count ( $ info [ 0 ] [ 'args' ] ) ? $ info [ 0 ] [ 'args' ] : '' ) , 'file' => $ info [ 0 ] [ 'file' ] , 'line' => $ info [ 0 ] [ 'line' ] , ] ; } | empty for Unix Timestamp |
54,043 | public function set ( $ value , $ key = null ) { if ( is_null ( $ key ) ) { $ this -> registry [ ] = $ value ; } else { $ this -> registry [ $ key ] = $ value ; } return $ this ; } | Sets the value in the registry by key . Returns the current object . |
54,044 | public function delete ( $ key ) { if ( $ this -> has ( $ key ) ) { unset ( $ this -> registry [ $ key ] ) ; return true ; } return false ; } | Delete an record from the registry by key . Returns the delete status . |
54,045 | protected function runScp ( $ file , $ destination_path , $ server = null , $ verbose = false ) { $ recursive_option = '' ; if ( is_dir ( $ file ) ) { $ recursive_option = ' -r' ; } $ server = $ server ? $ server : $ this -> hostNameForConfigFile ( ) ; $ ssh_config_file = $ _SERVER [ 'HOME' ] . '/.ssh/config' ; $ full_... | Runs scp . |
54,046 | protected function runSSH ( $ command , $ server = null ) { $ server = $ server ? $ server : $ this -> hostNameForConfigFile ( ) ; $ ssh_config_file = $ _SERVER [ 'HOME' ] . '/.ssh/config' ; $ full_command = "ssh -F $ssh_config_file -t $server '$command'" ; $ this -> info ( $ full_command ) ; passthru ( $ full_command ... | Runs ssh command on server . |
54,047 | protected function execSSH ( $ command , $ server = null ) { $ server = $ server ? $ server : $ this -> hostNameForConfigFile ( ) ; $ ssh_config_file = $ _SERVER [ 'HOME' ] . '/.ssh/config' ; $ full_command = "ssh -F $ssh_config_file -t $server '$command'" ; $ this -> info ( $ full_command ) ; return shell_exec ( $ ful... | Exec ssh command on server . |
54,048 | public function shortClassName ( ) { if ( ! isset ( $ this -> _data [ 'shortClassName' ] ) ) { $ this -> _data [ 'shortClassName' ] = \ Yii :: $ app -> czaHelper -> naming -> shortClassName ( $ this ) ; } return $ this -> _data [ 'shortClassName' ] ; } | Returns the form name that this widget class should use . |
54,049 | public function add ( $ step , $ callback ) { ( new \ Phramework \ Validate \ EnumValidator ( [ self :: STEP_BEFORE_AUTHENTICATION_CHECK , self :: STEP_AFTER_AUTHENTICATION_CHECK , self :: STEP_AFTER_CALL_URISTRATEGY , self :: STEP_BEFORE_CALL_URISTRATEGY , self :: STEP_BEFORE_CLOSE , self :: STEP_FINALLY , self :: STE... | Add a step callback |
54,050 | public function configureApplication ( ) { $ config = file_get_contents ( $ this -> paths [ 'app' ] . '/config/config.yml' ) ; $ config = $ this -> parser -> parse ( $ config ) ; $ this -> project_name = $ config [ 'application' ] [ 'project_name' ] ; $ this -> routeCollection = $ this -> bindRouteCollection ( $ this -... | Configure the Umbrella Application |
54,051 | public function bindPaths ( array $ paths ) { foreach ( $ paths as $ key => $ val ) { $ paths [ $ key ] = realpath ( $ val ) ; } return $ paths ; } | Connect app paths to the Application |
54,052 | public function createBaseEm ( $ env ) { if ( $ env == 'dev' ) { $ devEnv = true ; } else { $ devEnv = false ; } AnnotationRegistry :: registerFile ( $ this -> paths [ 'root' ] . '/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php' ) ; AnnotationRegistry :: registerAutoloadNamespace ( 'Symfony... | Create the base Doctrine EntityManager |
54,053 | public function bindRouteCollection ( $ name = "" ) { $ routeCollection = new RouteCollection ( $ this -> paths [ 'app' ] . '/routes.yml' , $ this -> paths , $ name , $ this -> parser ) ; return $ routeCollection ; } | Bind RouteCollection to app |
54,054 | public function parseUri ( ) { $ uri = ( isset ( $ _SERVER [ 'REQUEST_URI' ] ) ? $ _SERVER [ 'REQUEST_URI' ] : null ) ; if ( isset ( $ uri ) ) { $ uri = '/' . ltrim ( trim ( $ uri ) , '/' ) ; $ uri = filter_var ( $ uri , FILTER_SANITIZE_URL ) ; return $ uri ; } else { throw new Exception ( "Error parsing URI please che... | Parse the URL |
54,055 | public function registerBackend ( AbstractBackend $ backend ) { if ( in_array ( $ backend , $ this -> backends , TRUE ) ) { throw new InvalidArgumentException ( 'Duplicate backend: ' . get_class ( $ backend ) ) ; } else { $ this -> backends [ ] = $ backend ; if ( $ this -> debug_logger ) { $ backend -> setDebugLogger (... | Register a new backend |
54,056 | public function getMachine ( string $ type ) { foreach ( $ this -> backends as $ b => $ backend ) { $ m = $ backend -> getMachine ( $ this , $ type ) ; if ( $ m !== null ) { return $ m ; } } return null ; } | Obtain machine from backends . |
54,057 | public function ref ( ... $ argv ) : Reference { $ type = $ argv [ 0 ] ; if ( $ type instanceof Reference ) { if ( count ( $ argv ) != 1 ) { throw new InvalidArgumentException ( 'The first argument is a Reference and more than one argument given.' ) ; } return clone $ type ; } if ( is_array ( $ type ) ) { if ( count ( ... | Get reference to state machine instance of given type and id . |
54,058 | public function nullRef ( string $ type ) : Reference { foreach ( $ this -> backends as $ b => $ backend ) { $ m = $ backend -> getMachine ( $ this , $ type ) ; if ( $ m !== null ) { $ ref = $ m -> nullRef ( ) ; if ( $ this -> debug_logger ) { $ this -> debug_logger -> afterReferenceCreated ( $ backend , $ ref ) ; } if... | Get reference to non - existent state machine instance of given type . You may want to invoke create or similar transition using this reference . |
54,059 | public static function glob ( string $ pattern , int $ flag = 0 , array $ data = [ ] ) { $ paths = glob ( $ pattern , $ flag ) ; extract ( $ data ) ; foreach ( $ paths as $ path ) { require ( $ path ) ; } } | Use glob to include multiple files |
54,060 | private function generateHeader ( ) { $ this -> logger -> debug ( "Generating raw frame header" ) ; $ this -> logger -> debug ( "Generated frame 1st byte: " . decbin ( $ this -> firstFrameByte ) . ", 2nd: " . decbin ( $ this -> secondFrameByte ) ) ; $ header = chr ( $ this -> firstFrameByte ) . chr ( $ this -> secondFr... | Generates raw frame headers . |
54,061 | public function contents ( ) { $ contents = $ this -> filesystem ( ) -> listContents ( $ this -> path ( ) ) ; $ returns = array ( ) ; foreach ( $ contents as $ content ) { $ returns [ ] = $ this -> flightcontrol -> get ( $ content [ "path" ] ) ; } return $ returns ; } | Get the objects inside the directory . |
54,062 | public function insertByAna ( \ Closure $ unfolder , $ start_value ) { $ insert = FixedFDirectory :: ana ( $ unfolder , $ start_value ) ; if ( $ insert -> isFile ( ) ) { throw new \ LogicException ( "Expected generated root node to be a directory, not a file." ) ; } $ inserter = array ( ) ; $ inserter [ 0 ] = function ... | Create a directory structure with an anamorphism an insert it in place of this directory . |
54,063 | public function getContents ( $ type , $ index = null , $ order = true ) { $ contents = [ ] ; $ files = $ this -> listFiles ( $ type ) ; foreach ( $ files as $ file ) { $ content = $ this -> load ( $ file ) ; $ contents [ $ this -> getIndex ( $ file , $ content , $ index ) ] = $ content ; } if ( $ order !== null ) { $ ... | Get all contents for the given type |
54,064 | public function listContents ( $ type ) { $ names = [ ] ; $ files = $ this -> listFiles ( $ type ) ; foreach ( $ files as $ file ) { $ names [ ] = static :: getName ( $ file ) ; } return $ names ; } | List of content names for the given type |
54,065 | public function getContent ( $ type , $ name ) { $ finder = $ this -> listFiles ( $ type ) -> name ( $ name . '.*' ) ; if ( ! $ finder -> count ( ) ) { throw new Exception ( sprintf ( 'No content directory find for type "%s" and name "%s" (in "%s").' , $ type , $ name , $ this -> directory ) ) ; } foreach ( $ finder as... | Get the content for the given type and name |
54,066 | public static function getName ( SplFileInfo $ file ) { $ name = $ file -> getRelativePathname ( ) ; return substr ( $ name , 0 , strrpos ( $ name , '.' ) ) ; } | Get the name of a file |
54,067 | public static function getFormat ( SplFileInfo $ file ) { $ name = $ file -> getRelativePathname ( ) ; $ ext = substr ( $ name , strrpos ( $ name , '.' ) + 1 ) ; switch ( $ ext ) { case 'md' : return 'markdown' ; case 'yml' : return 'yaml' ; default : return $ ext ; } } | Get the format of a file from its extension |
54,068 | protected function listFiles ( $ type ) { if ( ! isset ( $ this -> cache [ 'files' ] [ $ type ] ) ) { $ path = sprintf ( '%s/%s' , $ this -> directory , $ type ) ; if ( ! $ this -> files -> exists ( $ path ) ) { throw new Exception ( sprintf ( 'No content directory found for type "%s" (in "%s").' , $ type , $ this -> d... | List files for the given type |
54,069 | protected function getIndex ( SplFileInfo $ file , $ content , $ key = null ) { if ( $ key === null || ! isset ( $ content [ $ key ] ) ) { return static :: getName ( $ file ) ; } $ index = $ content [ $ key ] ; if ( $ index instanceof DateTime ) { return $ index -> format ( 'U' ) ; } return ( string ) $ index ; } | Get index of the given content for content lists |
54,070 | protected function load ( SplFileInfo $ file ) { $ path = $ file -> getPathName ( ) ; if ( ! isset ( $ this -> cache [ 'contents' ] [ $ path ] ) ) { $ data = $ this -> decoder -> decode ( $ file -> getContents ( ) , static :: getFormat ( $ file ) ) ; $ context = [ 'file' => $ file , 'data' => $ data ] ; if ( is_array (... | Get the file content |
54,071 | public function xhrFileUploadAction ( Request $ request ) { if ( ! $ request -> files -> has ( 'file' ) ) { return new JsonResponse ( array ( 'error' => 400 , 'error_message' => 'File to upload have to be under "file" key.' , ) , 400 ) ; } try { return new JsonResponse ( array ( 'file' => $ this -> container -> get ( '... | Media upload action throught XmlHttpRequest . |
54,072 | protected function assignGroupsToAssignment ( ) { $ assignment = fp_env ( 'ACACHA_FORGE_ASSIGNMENT' ) ; foreach ( $ this -> groups as $ group ) { $ uri = str_replace ( '{assignment}' , $ assignment , config ( 'forge-publish.assign_group_to_assignment_uri' ) ) ; $ uri = str_replace ( '{group}' , $ group , $ uri ) ; $ ur... | Assign groups to assignment |
54,073 | protected function askForGroups ( ) { $ default = 0 ; $ groups = $ this -> groups ( ) ; $ group_names = collect ( $ groups ) -> pluck ( 'name' ) -> toArray ( ) ; $ selected_group_names = $ this -> choice ( 'Groups?' , $ group_names , $ default , null , true ) ; $ groups = collect ( $ groups ) -> filter ( function ( $ g... | Ask for groups . |
54,074 | public function getFunction ( ) { return function ( $ pathName ) { $ data = $ this -> context -> getData ( ) ; if ( array_key_exists ( 'sys_pathNames' , $ data ) ) { if ( array_key_exists ( $ pathName , $ data [ 'sys_pathNames' ] ) ) { return $ this -> context -> renderString ( $ data [ 'sys_pathNames' ] [ $ pathName ]... | Gets the function that is passed to the rendering environment . |
54,075 | public function revokeAccessToken ( ) { $ grantType = $ this -> getRequest ( ) -> request -> get ( 'grant_type' ) ? $ this -> getRequest ( ) -> request -> get ( 'grant_type' ) : 'password' ; $ token = $ this -> getRequest ( ) -> request -> get ( 'token' ) ; if ( is_null ( $ token ) ) { throw new Exception \ InvalidRequ... | Revoke a access token |
54,076 | public function processResponse ( ) { $ rawResponse = $ this -> rawResponse ; if ( empty ( $ rawResponse ) ) { return ; } $ responseData = unpack ( "Ccommand/Cstatus/Nidentifier" , $ rawResponse ) ; $ this -> validateResponse ( $ responseData ) ; $ statusCode = $ responseData [ 'status' ] ; $ errorDescription = self ::... | Unpacks and process response data |
54,077 | public function validateResponse ( $ responseData ) { if ( $ responseData === false ) { throw new RuntimeException ( 'Unable to unpack response data' ) ; } if ( self :: ERROR_RESPONSE_COMMAND != $ responseData [ 'command' ] ) { throw new RuntimeException ( "Invalid APNS response packet command" ) ; } return $ this ; } | Validates response data |
54,078 | public function setCallArgument ( $ arg ) { $ this -> call_argument = $ arg ; $ this -> args = [ $ this -> call_function , $ this -> call_argument ] ; } | Set argument for call function |
54,079 | public static function generate_nested_array ( $ array_map , $ map_keys , $ bind_value ) { $ reference = & $ array_map ; while ( count ( $ map_keys ) > 0 ) { $ new_map = array_shift ( $ map_keys ) ; if ( ! is_array ( $ reference ) ) { $ reference = array ( ) ; } $ reference = & $ reference [ $ new_map ] ; } $ reference... | get a nested key based array |
54,080 | public static function validate_ip ( $ ip = '' ) { if ( empty ( $ ip ) ) return false ; return ( ip2long ( $ ip ) !== false ) ? true : false ; } | returns if an IP is valid |
54,081 | public static function clean_up_path ( $ path ) { if ( empty ( $ path ) ) return '' ; if ( strpos ( $ path , '\\' ) !== false ) { return str_replace ( "\\\\" , "\\" , $ path ) ; } else { return str_replace ( "//" , "/" , $ path ) ; } } | removes multiple slashes and backslashes |
54,082 | public static function trim_array ( $ array ) { if ( empty ( $ array ) || ! is_array ( $ array ) ) return $ array ; foreach ( $ array as $ key => $ value ) { $ array [ $ key ] = trim ( $ value ) ; } unset ( $ key , $ value ) ; return $ array ; } | trims the content of an array |
54,083 | public static function php_number_format ( $ number ) { preg_match ( '/[.,](\d+)$/' , $ number , $ matches ) ; $ num_decimals = strlen ( $ matches [ 1 ] ) ; return preg_replace ( '/[.,]/' , '' , $ number ) / pow ( 10 , $ num_decimals ) ; } | Take a number an re - format the number to the target decimal separator |
54,084 | public static function updateQS ( $ key , $ value , $ reverseorder = false , $ qs = '' ) { if ( empty ( $ qs ) ) { $ qs = $ _SERVER [ 'QUERY_STRING' ] ; } if ( $ reverseorder ) { if ( preg_match ( "/ascdesc=ASC/" , $ qs ) ) { $ qs = self :: updateQS ( 'ascdesc' , 'DESC' , 0 , $ qs ) ; } else { $ qs = self :: updateQS (... | update a parameter in a query string with a new value |
54,085 | public static function array_diff_multi ( $ array1 , $ array2 ) { $ res = array ( ) ; foreach ( $ array1 as $ entry ) { if ( ! in_array ( $ entry , $ array2 ) ) { $ res [ ] = $ entry ; } } return $ res ; } | Array_Diff Implementation for multi - dimensional arrays Can only handle 2 arrays |
54,086 | public static function usortByArrayKey ( & $ array , $ key , $ asc = SORT_ASC ) { $ sort_flags = array ( SORT_ASC , SORT_DESC ) ; if ( ! in_array ( $ asc , $ sort_flags ) ) throw new InvalidArgumentException ( 'sort flag only accepts SORT_ASC or SORT_DESC' ) ; $ cmp = function ( array $ a , array $ b ) use ( $ key , $ ... | Sort an array by a key |
54,087 | public static function make_bitly_url ( $ url , $ login = '' , $ appkey = 'R_f0b76fa0948d2cb9f223fb5387ad09ba' , $ format = 'xml' ) { $ bitly = 'http://api.bitly.com/v3/shorten?longUrl=' . urlencode ( $ url ) . '&login=' . urlencode ( $ login ) . '&apiKey=' . $ appkey . '&format=' . $ format ; $ response = file_get_con... | generates a bitly url |
54,088 | public static function assignByKey ( $ array , $ key , $ group = false ) { if ( empty ( $ array ) ) return $ array ; $ res = array ( ) ; foreach ( $ array as $ subthing ) { $ idx = null ; if ( is_object ( $ subthing ) && property_exists ( $ subthing , $ key ) ) { $ idx = $ subthing -> $ key ; } elseif ( is_array ( $ su... | Turn an array into an associative array assigned by the given key |
54,089 | protected function initStream ( $ stream ) { expect_type ( $ stream , [ 'stream resource' , 'string' ] , \ TypeError :: class , "Expected stream resource or uri (string), %s given" ) ; if ( is_string ( $ stream ) ) { $ stream = $ this -> openStream ( $ stream ) ; } $ meta = stream_get_meta_data ( $ stream ) ; if ( $ me... | Initialize a stream |
54,090 | protected function assertAttached ( ) : void { if ( ! isset ( $ this -> stream ) ) { throw new \ BadMethodCallException ( "Stream is not attached" ) ; } if ( ! is_resource ( $ this -> stream ) ) { throw new \ RuntimeException ( "Stream has closed unexpectedly" ) ; } } | Assert that a stream is attached . |
54,091 | public function detach ( ) { $ this -> assertAttached ( ) ; $ stream = $ this -> stream ; $ this -> stream = null ; return $ stream ; } | Detach the stream resource . The object is no longer usable . |
54,092 | public function getDependencies ( ) : array { $ dependencies = [ ] ; foreach ( $ this -> config [ 'dependencies' ] as $ dependency ) { $ dependencies [ ] = $ this -> wire ( $ dependency ) ; } return $ dependencies ; } | Class names of all view dependencies . |
54,093 | public function getEngines ( ) : array { $ engines = [ ] ; foreach ( $ this -> config [ 'engines' ] as $ engine ) { $ engines [ ] = $ this -> wire ( $ engine ) ; } return $ engines ; } | Get all the engines associated with view component . |
54,094 | public function resolve ( ContentInterface $ content ) { $ contentType = $ this -> contentTypeLoader -> retrieveAll ( ) -> filter ( function ( ContentTypeInterface $ contentType ) use ( $ content ) { return is_a ( $ content , $ contentType -> getContentClass ( ) ) ; } ) -> first ( ) ; if ( ! $ contentType ) { throw new... | Resolve given Content into Synapse internal content class . |
54,095 | public function postCreate ( PostRequest $ request ) { $ command = new CreatePostCommand ( $ request -> all ( ) ) ; try { $ this -> bus -> execute ( $ command ) ; } catch ( ValidationException $ e ) { return Redirect :: to ( \ OogleeBConfig :: get ( 'config.post_routes.base_uri_admin' ) . '/post/create' ) -> withErrors... | Create new Post |
54,096 | public function createCopy ( ) : AbstractResize { $ this -> createCanvas ( ) ; $ this -> intermediate [ 'copy' ] = imagecreatefrompng ( $ this -> source [ 'path' ] . $ this -> source [ 'file' ] ) ; if ( $ this -> intermediate [ 'copy' ] === false ) { throw new \ Exception ( 'Call to imagecreatefrompng failed' ) ; } $ t... | Create the image in the required format |
54,097 | protected function saveFile ( ) : AbstractResize { $ result = imagepng ( $ this -> canvas [ 'canvas' ] , $ this -> path . $ this -> file , $ this -> canvas [ 'quality' ] ) ; if ( $ result === false ) { throw new \ Exception ( 'Unable to save new image' ) ; } return $ this ; } | Attempt to save the new image file |
54,098 | public static function getPackageInfo ( $ format = 'v/p (\vn)' ) { try { $ v = self :: getPackageVendor ( ) ; } catch ( LogicException $ vendorException ) { } try { $ p = self :: getPackageName ( ) ; } catch ( LogicException $ packageException ) { if ( isset ( $ vendorException ) ) { $ packageException = new LogicExcep... | Get the Package info in a given format . |
54,099 | public function insert ( ... $ field_values ) { if ( $ this -> is_done ) { throw new RuntimeException ( 'This batch insert is already done' ) ; } if ( count ( $ field_values ) == $ this -> fields_num ) { $ this -> rows [ ] = $ this -> connection -> prepare ( $ this -> row_prepare_pattern , ... $ field_values ) ; if ( c... | Insert a row with the given field values . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.