idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
6,700
public function getCalendarId ( EntityInterface $ entity , ArrayObject $ options , $ map = null ) { $ result = null ; if ( empty ( $ options [ 'calendar' ] ) ) { return $ result ; } $ result = $ options [ 'calendar' ] -> id ; return $ result ; }
Get Calendar ID .
6,701
public function getCalendarEventEndDate ( EntityInterface $ entity , ArrayObject $ options , $ map = null ) { $ source = $ map -> end_date -> options -> source ; $ ts = Time :: parse ( $ entity -> get ( $ source ) ) ; $ endDate = $ ts -> modify ( '+ 1 hour' ) -> i18nFormat ( 'yyyy-MM-dd HH:mm' ) ; $ result = new Time (...
Get Calendar Event end_date
6,702
public function getCalendarEventTitle ( EntityInterface $ entity , ArrayObject $ options , $ map = null ) { $ table = TableRegistry :: getTableLocator ( ) -> get ( $ entity -> source ( ) ) ; $ displayField = $ entity -> get ( $ table -> getDisplayField ( ) ) ; $ result = sprintf ( "%s - %s" , Inflector :: humanize ( $ ...
Get Calendar Event Title
6,703
public function getCalendarEventContent ( EntityInterface $ entity , ArrayObject $ options , $ map = null ) { $ source = $ map -> content -> options -> source ; $ result = $ entity -> get ( $ source ) ; if ( ! empty ( $ options [ 'viewEntity' ] ) ) { $ url = $ options [ 'viewEntity' ] -> Html -> link ( __ ( 'Source' ) ...
Get Calendar Event Content
6,704
public function getParameterValue ( $ name ) { if ( ! isset ( $ this -> parameterValues [ $ name ] ) ) { throw NoSuchParameterException :: forParameterName ( $ name , $ this -> installerName ) ; } return $ this -> parameterValues [ $ name ] ; }
Returns the value of the given parameter .
6,705
public function set ( $ name ) { $ filters = array_unique ( $ this -> session -> get ( 'filters' , array ( ) ) ) ; if ( in_array ( $ name , $ filters ) ) { return array_search ( $ name , $ filters ) ; } $ filterKey = 'filter_' . sha1 ( microtime ( true ) . mt_rand ( ) . $ name ) ; $ filters [ $ filterKey ] = $ name ; $...
set filter .
6,706
public function get ( $ key , $ default = null , $ fallback = true ) { return $ this -> replacePlaceholders ( $ this -> getRaw ( $ key , $ default , $ fallback ) , $ fallback ) ; }
Returns the value of a configuration key .
6,707
public function getRaw ( $ key , $ default = null , $ fallback = true ) { if ( isset ( self :: $ compositeKeys [ $ key ] ) ) { return array_replace_recursive ( is_array ( $ default ) ? $ default : array ( ) , $ fallback && $ this -> baseConfig ? $ this -> baseConfig -> getRaw ( $ key ) : array ( ) , $ this -> filterByK...
Returns the raw value of a configuration key .
6,708
public function contains ( $ key , $ fallback = true ) { if ( ! isset ( self :: $ compositeKeys [ $ key ] ) && ! isset ( self :: $ keys [ $ key ] ) ) { throw NoSuchConfigKeyException :: forKey ( $ key ) ; } if ( array_key_exists ( $ key , $ this -> values ) ) { return true ; } if ( isset ( self :: $ compositeKeys [ $ k...
Returns whether a configuration key is set .
6,709
public function set ( $ key , $ value ) { if ( isset ( self :: $ compositeKeys [ $ key ] ) ) { $ this -> assertArray ( $ key , $ value ) ; $ this -> removeByKeyPrefix ( $ key . '.' ) ; foreach ( $ value as $ k => $ v ) { $ this -> set ( $ key . '.' . $ k , $ v ) ; } return ; } if ( ! isset ( self :: $ keys [ $ key ] ) ...
Sets the value of a configuration key .
6,710
public function remove ( $ key ) { if ( isset ( self :: $ compositeKeys [ $ key ] ) ) { $ this -> removeByKeyPrefix ( $ key . '.' ) ; return ; } if ( ! isset ( self :: $ keys [ $ key ] ) ) { throw NoSuchConfigKeyException :: forKey ( $ key ) ; } unset ( $ this -> values [ $ key ] ) ; }
Removes a configuration key .
6,711
public function toFlatRawArray ( $ includeFallback = true ) { return $ includeFallback && $ this -> baseConfig ? array_replace ( $ this -> baseConfig -> toFlatRawArray ( ) , $ this -> values ) : $ this -> values ; }
Returns all raw configuration values as flat array .
6,712
public function toRawArray ( $ includeFallback = true ) { $ values = array ( ) ; foreach ( $ this -> values as $ key => $ value ) { $ this -> addKeyValue ( $ key , $ value , $ values ) ; } return $ includeFallback && $ this -> baseConfig ? array_replace_recursive ( $ this -> baseConfig -> toRawArray ( ) , $ values ) : ...
Returns all raw configuration values as nested array .
6,713
public function isEmpty ( $ includeFallback = true ) { if ( ! empty ( $ this -> values ) ) { return false ; } return $ includeFallback && $ this -> baseConfig ? $ this -> baseConfig -> isEmpty ( true ) : true ; }
Returns whether the configuration is empty .
6,714
public function get ( $ repositoryPath ) { if ( ! isset ( $ this -> conflicts [ $ repositoryPath ] ) ) { throw new OutOfBoundsException ( sprintf ( 'No conflict is stored for the path "%s".' , $ repositoryPath ) ) ; } return $ this -> conflicts [ $ repositoryPath ] ; }
Get a path conflict .
6,715
public static function forRepositoryPath ( $ repositoryPath , $ moduleName , Exception $ cause = null ) { return new static ( sprintf ( 'The path "%s" is already mapped in module "%s".' , $ repositoryPath , $ moduleName ) , 0 , $ cause ) ; }
Creates an exception for a duplicate repository path .
6,716
public function load ( $ resource , $ type = null ) : RepositoryInterface { $ repository = $ this -> resolveLoader ( $ resource , $ type ) -> load ( $ resource , $ type ) ; return $ repository ; }
Loads a resource such as a file or an inline configuration
6,717
public function getUserId ( ) { if ( ! $ this -> authSource -> isAuthenticated ( ) ) { return NULL ; } $ attributes = $ this -> authSource -> getAttributes ( ) ; if ( ! array_key_exists ( $ this -> usernameAttribute , $ attributes ) ) { throw new SimpleSAML_Error_Exception ( 'Missing username attribute ' . var_export (...
Retrieve the current user ID .
6,718
public function getIdentity ( ) { $ userId = $ this -> getUserId ( ) ; if ( $ userId === NULL ) { return NULL ; } $ identity = SimpleSAML \ Module :: getModuleURL ( 'openidProvider/user.php/' . $ userId ) ; return $ identity ; }
Retrieve the current identity .
6,719
public function addTrustRoot ( $ identity , $ trustRoot ) { assert ( 'is_string($identity)' ) ; assert ( 'is_string($trustRoot)' ) ; $ trs = $ this -> getTrustRoots ( $ identity ) ; if ( ! in_array ( $ trustRoot , $ trs , TRUE ) ) { $ trs [ ] = $ trustRoot ; } $ this -> saveTrustRoots ( $ identity , $ trs ) ; }
Add the given trust root to the user .
6,720
public function removeTrustRoot ( $ identity , $ trustRoot ) { assert ( 'is_string($identity)' ) ; assert ( 'is_string($trustRoot)' ) ; $ trs = $ this -> getTrustRoots ( $ identity ) ; $ i = array_search ( $ trustRoot , $ trs , TRUE ) ; if ( $ i === FALSE ) { return ; } array_splice ( $ trs , $ i , 1 , array ( ) ) ; $ ...
Remove the given trust root from the trust list of the user .
6,721
private function isTrusted ( $ identity , $ trustRoot ) { assert ( 'is_string($identity)' ) ; assert ( 'is_string($trustRoot)' ) ; $ trs = $ this -> getTrustRoots ( $ identity ) ; return in_array ( $ trustRoot , $ trs , TRUE ) ; }
Is the given trust root trusted by the user?
6,722
private function getStateURL ( $ page , array $ state ) { assert ( 'is_string($page)' ) ; $ stateId = SimpleSAML_Auth_State :: saveState ( $ state , 'openidProvider:resumeState' ) ; $ stateURL = SimpleSAML \ Module :: getModuleURL ( 'openidProvider/' . $ page ) ; $ stateURL = \ SimpleSAML \ Utils \ HTTP :: addURLParame...
Save the state and return a URL that can contain a reference to the state .
6,723
private function sendResponse ( Auth_OpenID_ServerResponse $ response ) { SimpleSAML \ Logger :: debug ( 'openidProvider::sendResponse' ) ; $ webresponse = $ this -> server -> encodeResponse ( $ response ) ; if ( $ webresponse -> code !== 200 ) { header ( 'HTTP/1.1 ' . $ webresponse -> code , TRUE , $ webresponse -> co...
Send an OpenID response .
6,724
public function receiveRequest ( ) { $ request = $ this -> server -> decodeRequest ( ) ; if ( ! in_array ( $ request -> mode , array ( 'checkid_immediate' , 'checkid_setup' ) , TRUE ) ) { $ this -> sendResponse ( $ this -> server -> handleRequest ( $ request ) ) ; } $ state = array ( 'request' => $ request , ) ; $ this...
Receive an incoming request .
6,725
private function addParameters ( ContainerBuilder $ container , array $ parameters ) { foreach ( $ parameters as $ key => $ value ) { $ container -> setParameter ( 'apoutchika_media.' . $ key , $ value ) ; } }
Add parameter in container .
6,726
protected function getOptionUrlParameters ( $ key , ViewData $ data ) { $ parameters = $ data -> getUrlParameters ( ) ; if ( isset ( $ parameters [ $ this -> getRequestField ( ) ] ) ) { $ parameters [ $ this -> getRequestField ( ) ] [ ] = $ key ; } else { $ parameters [ $ this -> getRequestField ( ) ] = [ $ key ] ; } r...
Returns url with selected term applied .
6,727
protected function getFilterManagerResponse ( Request $ request , $ managerName ) { return [ 'filter_manager' => $ this -> get ( ONGRFilterManagerExtension :: getFilterManagerId ( $ managerName ) ) -> handleRequest ( $ request ) ] ; }
Returns search response results from filter manager .
6,728
public function jsonAction ( Request $ request , $ managerName ) { $ data = $ this -> get ( ONGRFilterManagerExtension :: getFilterManagerId ( $ managerName ) ) -> handleRequest ( $ request ) -> getSerializableData ( ) ; $ response = new JsonResponse ( $ data ) ; if ( $ request -> query -> has ( 'pretty' ) ) { $ respon...
Returns JSON response with search response data .
6,729
public function getMimeType ( ) { if ( $ this -> file instanceof UploadedFile ) { return $ this -> file -> getClientMimeType ( ) ; } return $ this -> file -> getMimeType ( ) ; }
Get mime type of file .
6,730
public function getName ( ) { if ( $ this -> file instanceof UploadedFile ) { return $ this -> file -> getClientOriginalName ( ) ; } return $ this -> file -> getFilename ( ) ; }
Get original name of file .
6,731
public function getType ( ) { $ mimeType = preg_replace ( '#^([^/]+)/.*$#' , '$1' , $ this -> getMimeType ( ) ) ; if ( $ mimeType == 'video' ) { return Media :: VIDEO ; } if ( $ mimeType == 'audio' ) { return Media :: AUDIO ; } if ( $ mimeType == 'image' ) { return Media :: IMAGE ; } $ extension = $ this -> getExtensio...
Get type of file . It s a constace in Media class .
6,732
public function load ( Module $ containingModule , ModuleList $ modules ) { if ( null !== $ this -> state ) { throw new AlreadyLoadedException ( 'The mapping is already loaded.' ) ; } $ filesystemPaths = array ( ) ; $ pathMappings = array ( ) ; $ loadErrors = array ( ) ; foreach ( $ this -> pathReferences as $ relative...
Loads the mapping .
6,733
public function unload ( ) { if ( null === $ this -> state ) { throw new NotLoadedException ( 'The mapping is not loaded.' ) ; } $ conflictsToRelease = $ this -> conflicts ; $ this -> conflicts = array ( ) ; foreach ( $ conflictsToRelease as $ conflict ) { $ conflict -> removeMapping ( $ this ) ; } $ this -> filesystem...
Unloads the mapping .
6,734
public function addConflict ( PathConflict $ conflict ) { if ( null === $ this -> state ) { throw new NotLoadedException ( 'The mapping is not loaded.' ) ; } if ( ! Path :: isBasePath ( $ this -> repositoryPath , $ conflict -> getRepositoryPath ( ) ) ) { throw new InvalidArgumentException ( sprintf ( 'The conflicting p...
Adds a conflict to the mapping .
6,735
public function removeConflict ( PathConflict $ conflict ) { if ( null === $ this -> state ) { throw new NotLoadedException ( 'The mapping is not loaded.' ) ; } $ repositoryPath = $ conflict -> getRepositoryPath ( ) ; if ( ! isset ( $ this -> conflicts [ $ repositoryPath ] ) || $ conflict !== $ this -> conflicts [ $ re...
Removes a conflict from the mapping .
6,736
public function getConflictingModules ( ) { if ( null === $ this -> state ) { throw new NotLoadedException ( 'The mapping is not loaded.' ) ; } $ collection = new ModuleList ( ) ; foreach ( $ this -> conflicts as $ conflict ) { foreach ( $ conflict -> getMappings ( ) as $ mapping ) { if ( $ this === $ mapping ) { conti...
Returns all modules with conflicting path mappings .
6,737
public function getConflictingMappings ( ) { if ( null === $ this -> state ) { throw new NotLoadedException ( 'The mapping is not loaded.' ) ; } $ conflictingMappings = array ( ) ; foreach ( $ this -> conflicts as $ conflict ) { foreach ( $ conflict -> getMappings ( ) as $ mapping ) { if ( $ this === $ mapping ) { cont...
Returns all conflicting path mappings .
6,738
public function setClassName ( $ className ) { Assert :: stringNotEmpty ( $ className , 'The class name must be a non-empty string. Got: %s' ) ; $ pos = strrpos ( $ className , '\\' ) ; if ( false === $ pos ) { $ this -> namespaceName = '' ; $ this -> shortClassName = $ className ; } else { $ this -> namespaceName = su...
Sets the fully - qualified name of the factory class .
6,739
public function setDirectory ( $ directory ) { Assert :: stringNotEmpty ( $ directory , 'The factory directory must be a non-empty string. Got: %s' ) ; $ this -> directory = Path :: canonicalize ( $ directory ) ; return $ this ; }
Sets the path to the directory holding the factory class file .
6,740
public function setFilePath ( $ filePath ) { Assert :: stringNotEmpty ( $ filePath , 'The factory file path must be a non-empty string. Got: %s' ) ; $ this -> setDirectory ( Path :: getDirectory ( $ filePath ) ) ; $ this -> setFileName ( Path :: getFilename ( $ filePath ) ) ; return $ this ; }
Sets the absolute file path of the factory class file .
6,741
public function addImplementedInterface ( $ interfaceName ) { Assert :: stringNotEmpty ( $ interfaceName , 'The interface name must be a non-empty string. Got: %s' ) ; $ this -> implementedInterfaces [ $ interfaceName ] = true ; return $ this ; }
Adds an implemented interface to the class definition .
6,742
public function addImport ( Import $ import ) { if ( isset ( $ this -> imports [ $ import -> getClassName ( ) ] ) ) { return $ this ; } $ symbol = $ import -> getAlias ( ) ? : $ import -> getShortClassName ( ) ; if ( isset ( $ this -> importedSymbols [ $ symbol ] ) ) { throw new RuntimeException ( sprintf ( 'The symbol...
Adds an import statement to the class file .
6,743
public function removeImport ( $ className ) { if ( isset ( $ this -> imports [ $ className ] ) ) { $ import = $ this -> imports [ $ className ] ; $ symbol = $ import -> getAlias ( ) ? : $ import -> getShortClassName ( ) ; unset ( $ this -> imports [ $ className ] ) ; unset ( $ this -> importedSymbols [ $ symbol ] ) ; ...
Removes an import statement from the class file .
6,744
public function getMethod ( $ name ) { if ( ! isset ( $ this -> methods [ $ name ] ) ) { throw new OutOfBoundsException ( sprintf ( 'The method "%s" does not exist.' , $ name ) ) ; } return $ this -> methods [ $ name ] ; }
Returns the method with the given name .
6,745
public function addMethod ( Method $ method ) { if ( isset ( $ this -> methods [ $ method -> getName ( ) ] ) ) { throw new RuntimeException ( sprintf ( 'The method "%s" exists already.' , $ method -> getName ( ) ) ) ; } $ this -> methods [ $ method -> getName ( ) ] = $ method ; $ method -> setClass ( $ this ) ; return ...
Adds a method to the class .
6,746
public function add ( ) { $ this -> request -> allowMethod ( [ 'post' , 'patch' , 'put' ] ) ; $ response = [ 'success' => false , 'data' => [ ] , 'errors' => [ ] , ] ; $ calendarsTable = TableRegistry :: get ( 'Calendars' ) ; $ data = $ this -> request -> getData ( ) ; $ data = is_array ( $ data ) ? $ data : [ ] ; if (...
Create Event via AJAX call
6,747
public function view ( ) { $ response = [ 'success' => false , 'data' => [ ] , 'errors' => [ ] ] ; if ( $ this -> request -> is ( [ 'post' , 'patch' , 'put' ] ) ) { $ data = $ this -> request -> getData ( ) ; $ result = $ this -> CalendarEvents -> getEventInfo ( $ data [ 'id' ] ) ; if ( ! empty ( $ result ) ) { $ respo...
View Event via AJAX
6,748
public function getEventTypes ( ) { $ this -> request -> allowMethod ( [ 'post' , 'patch' , 'put' ] ) ; $ calendarsTable = TableRegistry :: Get ( 'Qobo/Calendar.Calendars' ) ; $ eventTypes = [ ] ; $ data = $ this -> request -> getData ( ) ; $ calendar = $ calendarsTable -> get ( $ data [ 'calendar_id' ] ) ; $ types = $...
Get Event types based on the calendar id
6,749
public function eventTypeConfig ( ) { $ this -> request -> allowMethod ( [ 'post' , 'put' , 'patch' ] ) ; $ response = [ 'success' => false , 'data' => [ ] , 'errors' => [ ] , ] ; $ data = $ this -> request -> getData ( ) ; try { $ config = ObjectFactory :: getConfig ( null , 'Event' , $ data [ 'event_type' ] ) ; if ( ...
Event Type Config getter method
6,750
public function setData ( $ totalItems , $ currentPage , $ itemsPerPage = 12 , $ maxPages = 10 ) { $ this -> totalItems = $ totalItems ; $ this -> currentPage = $ currentPage ; $ this -> itemsPerPage = $ itemsPerPage ; $ this -> maxPages = $ maxPages ; $ this -> numPages = ( int ) ceil ( $ this -> totalItems / $ this -...
Initializes data for pagination .
6,751
public static function forUuid ( Uuid $ uuid , Exception $ cause = null ) { return new static ( sprintf ( 'The asset mapping "%s" exists already.' , $ uuid -> toString ( ) ) , 0 , $ cause ) ; }
Creates an exception for a UUID that exists already .
6,752
public static function getColumnsConfiguration ( array $ data ) { $ config = array ( ) ; $ lastColumns = null ; foreach ( array ( 'large' , 'medium' , 'small' ) as $ media ) { $ columns = isset ( $ data [ 'rs_columns_' . $ media ] ) ? $ data [ 'rs_columns_' . $ media ] : null ; if ( ! $ columns ) { $ columns = $ lastCo...
Generate the columns configuration
6,753
protected function parseImports ( RepositoryInterface $ repository , string $ file ) : RepositoryInterface { if ( ! isset ( $ repository [ self :: IMPORT_KEY ] ) ) { return $ repository ; } if ( ! is_array ( $ repository [ self :: IMPORT_KEY ] ) ) { $ keyName = self :: IMPORT_KEY ; $ message = "The \"{$keyName}\" key s...
Parses the repositories in imports key
6,754
protected function readFile ( string $ file ) : string { if ( is_file ( $ file ) === false ) { throw new BadFileException ( "The file \"{$file}\" is not a file." , $ file ) ; } if ( is_readable ( $ file ) === false ) { throw new BadFileException ( "Unable to open \"{$file}\" as the file is not readable." , $ file ) ; }...
Reads a file
6,755
public static function maskErrors ( $ mask ) { if ( ! is_int ( $ mask ) ) { throw new \ InvalidArgumentException ( 'Invalid input parameters.' ) ; } $ currentEnabled = error_reporting ( ) ; self :: $ logLevelStack [ ] = array ( $ currentEnabled , self :: $ logMask ) ; $ currentEnabled &= ~ $ mask ; error_reporting ( $ ...
Disable reporting of the given log levels .
6,756
public static function popErrorMask ( ) { $ lastMask = array_pop ( self :: $ logLevelStack ) ; error_reporting ( $ lastMask [ 0 ] ) ; self :: $ logMask = $ lastMask [ 1 ] ; }
Pop an error mask .
6,757
public function saveAttendee ( array $ entity ) : array { $ response = [ 'status' => false , 'errors' => [ ] , 'entity' => null , ] ; if ( empty ( $ entity [ 'id' ] ) ) { unset ( $ entity [ 'id' ] ) ; } $ query = $ this -> find ( ) -> where ( [ 'source' => $ entity [ 'source' ] , 'source_id' => $ entity [ 'source_id' ]...
Save Calendar Attendees
6,758
public function saveContent ( $ key , $ content ) { $ this -> master -> getFilesystem ( ) -> write ( $ key , $ content , true ) ; foreach ( $ this -> slaves as $ slave ) { $ slave -> getFilesystem ( ) -> write ( $ key , $ content , true ) ; } }
Save file from string in master and slaves .
6,759
public function delete ( $ key ) { $ this -> master -> getFilesystem ( ) -> delete ( $ key ) ; foreach ( $ this -> slaves as $ slave ) { $ slave -> getFilesystem ( ) -> delete ( $ key ) ; } }
delete file in master and slaves .
6,760
public function setAlias ( $ alias ) { $ aliasManipulator = new AliasManipulator ( $ this -> originalDir , $ this -> alias ) ; $ aliasManipulator -> setAlias ( $ alias ) ; return $ aliasManipulator ; }
Set alias and return AliasManipulator .
6,761
public function getChainExtendedClasses ( ) { $ chainExtendMap = [ ] ; $ paths = $ this -> scanner -> getFilePaths ( ) ; foreach ( $ paths as $ path ) { $ aModule = [ ] ; include ( $ path ) ; if ( isset ( $ aModule [ 'extend' ] ) ) { $ chainExtendMap = array_merge ( $ chainExtendMap , array_flip ( $ aModule [ 'extend' ...
Get all module chain extensions . Key is module class value is shop class .
6,762
private function detectCharset ( ServerRequestInterface $ request ) { $ accept = $ request -> getHeaderLine ( 'Accept-Charset' ) ; return $ this -> negotiateHeader ( $ accept , new CharsetNegotiator ( ) , $ this -> charsets ) ; }
Returns the charset accepted .
6,763
public function apply ( $ aliasName = null ) { $ reset = false ; if ( $ aliasName === null ) { $ aliasName = $ this -> mediaManager -> getOriginalDir ( ) ; $ reset = true ; } $ this -> updateFile ( $ this -> image ) ; $ this -> updateFocus ( $ this -> media ) ; $ fs = $ this -> mediaManager -> getFilesystemManipulator ...
Apply the filter .
6,764
public function buildLookup ( ) { $ lookup = array_combine ( array_merge ( range ( 'A' , 'Z' ) , range ( 2 , 7 ) ) , range ( 0 , 31 ) ) ; $ this -> setLookup ( $ lookup ) ; }
Build the base32 lookup table
6,765
public function setInitKey ( $ key ) { if ( preg_match ( '/^[' . implode ( '' , array_keys ( $ this -> getLookup ( ) ) ) . ']+$/' , $ key ) == false ) { throw new \ InvalidArgumentException ( 'Invalid base32 hash!' ) ; } $ this -> initKey = $ key ; return $ this ; }
Set the initialization key for the object
6,766
public function validateCode ( $ code , $ initKey = null , $ timestamp = null , $ range = null ) { if ( strlen ( $ code ) !== $ this -> getCodeLength ( ) ) { throw new \ InvalidArgumentException ( 'Incorrect code length' ) ; } $ range = ( $ range == null ) ? $ this -> getRange ( ) : $ range ; $ timestamp = ( $ timestam...
Validate the given code
6,767
public function generateOneTime ( $ initKey = null , $ timestamp = null ) { $ initKey = ( $ initKey == null ) ? $ this -> getInitKey ( ) : $ initKey ; $ timestamp = ( $ timestamp == null ) ? $ this -> generateTimestamp ( ) : $ timestamp ; $ hash = hash_hmac ( 'sha1' , pack ( 'N*' , 0 ) . pack ( 'N*' , $ timestamp ) , $...
Generate a one - time code
6,768
public function truncateHash ( $ hash ) { $ offset = ord ( $ hash [ 19 ] ) & 0xf ; return ( ( ( ord ( $ hash [ $ offset + 0 ] ) & 0x7f ) << 24 ) | ( ( ord ( $ hash [ $ offset + 1 ] ) & 0xff ) << 16 ) | ( ( ord ( $ hash [ $ offset + 2 ] ) & 0xff ) << 8 ) | ( ord ( $ hash [ $ offset + 3 ] ) & 0xff ) ) % pow ( 10 , $ this...
Truncate the given hash down to just what we need
6,769
public function base32_decode ( $ hash ) { $ lookup = $ this -> getLookup ( ) ; if ( preg_match ( '/^[' . implode ( '' , array_keys ( $ lookup ) ) . ']+$/' , $ hash ) == false ) { throw new \ InvalidArgumentException ( 'Invalid base32 hash!' ) ; } $ hash = strtoupper ( $ hash ) ; $ buffer = 0 ; $ length = 0 ; $ binary ...
Base32 decoding function
6,770
public static function validate ( $ rating ) { if ( \ is_numeric ( $ rating ) && $ rating > - 0.01 && $ rating < 5.01 ) { \ preg_match ( '/([0-9].[0-9])/' , $ rating , $ matches ) ; $ matches [ 0 ] = \ floatval ( $ matches [ 0 ] ) ; return ( ! empty ( $ matches [ 0 ] ) && $ matches [ 0 ] <= 5.0 && $ matches [ 0 ] >= 0....
The rating of the video . Allowed values are float numbers in the range 0 . 0 to 5 . 0 .
6,771
public static function forUuidAndModule ( Uuid $ uuid , $ moduleName , Exception $ cause = null ) { return new static ( sprintf ( 'The binding with UUID "%s" does not exist in module "%s".' , $ uuid -> toString ( ) , $ moduleName ) , 0 , $ cause ) ; }
Creates an exception for a UUID that was not found in a given module .
6,772
public static function forInstallerNameAndModuleName ( $ installerName , $ moduleName , Exception $ cause = null ) { return new static ( sprintf ( 'The installer "%s" does not exist in module "%s".' , $ installerName , $ moduleName ) , 0 , $ cause ) ; }
Creates an exception for an installer name that was not found in a given module .
6,773
public function buildSearchRequest ( Request $ request ) { $ search = new SearchRequest ( ) ; $ filters = $ this -> all ( ) ; foreach ( $ filters as $ name => $ filter ) { $ state = $ filter -> getState ( $ request ) ; $ state -> setName ( $ name ) ; $ search -> set ( $ name , $ state ) ; } return $ search ; }
Builds search request according to given filters .
6,774
public function buildSearch ( SearchRequest $ request , $ filters = null ) { $ search = new Search ( ) ; $ filters = $ filters ? $ filters : $ this -> all ( ) ; foreach ( $ filters as $ name => $ filter ) { $ filter -> modifySearch ( $ search , $ request -> get ( $ name ) , $ request ) ; } return $ search ; }
Builds elastic search query by given SearchRequest and filters .
6,775
private static function parseHomeDirectory ( ) { try { $ homeDir = System :: parseHomeDirectory ( ) ; System :: denyWebAccess ( $ homeDir ) ; return $ homeDir ; } catch ( InvalidConfigException $ e ) { return null ; } }
Parses the system context for a home directory .
6,776
public function start ( ) { if ( $ this -> started ) { throw new LogicException ( 'Puli is already started' ) ; } if ( null !== $ this -> rootDir ) { $ this -> context = $ this -> createProjectContext ( $ this -> rootDir , $ this -> env ) ; $ bootstrapFile = $ this -> context -> getConfig ( ) -> get ( Config :: BOOTSTR...
Starts the service container .
6,777
public function setRootDirectory ( $ rootDir ) { if ( $ this -> started ) { throw new LogicException ( 'Puli is already started' ) ; } Assert :: nullOrDirectory ( $ rootDir ) ; $ this -> rootDir = $ rootDir ? Path :: canonicalize ( $ rootDir ) : null ; }
Sets the root directory of the managed Puli project .
6,778
public function setEnvironment ( $ env ) { if ( $ this -> started ) { throw new LogicException ( 'Puli is already started' ) ; } Assert :: oneOf ( $ env , Environment :: all ( ) , 'The environment must be one of: %2$s. Got: %s' ) ; $ this -> env = $ env ; }
Sets the environment of the managed Puli project .
6,779
public function getRepository ( ) { if ( ! $ this -> started ) { throw new LogicException ( 'Puli was not started' ) ; } if ( ! $ this -> context instanceof ProjectContext ) { return null ; } if ( ! $ this -> repo ) { $ this -> repo = $ this -> getFactory ( ) -> createRepository ( ) ; } return $ this -> repo ; }
Returns the resource repository of the project .
6,780
public function getDiscovery ( ) { if ( ! $ this -> started ) { throw new LogicException ( 'Puli was not started' ) ; } if ( ! $ this -> context instanceof ProjectContext ) { return null ; } if ( ! $ this -> discovery ) { $ this -> discovery = $ this -> getFactory ( ) -> createDiscovery ( $ this -> getRepository ( ) ) ...
Returns the resource discovery of the project .
6,781
public function getConfigFileManager ( ) { if ( ! $ this -> started ) { throw new LogicException ( 'Puli was not started' ) ; } if ( ! $ this -> configFileManager && $ this -> context -> getHomeDirectory ( ) ) { $ this -> configFileManager = new ConfigFileManagerImpl ( $ this -> context , $ this -> getJsonStorage ( ) )...
Returns the configuration file manager .
6,782
public function getRootModuleFileManager ( ) { if ( ! $ this -> started ) { throw new LogicException ( 'Puli was not started' ) ; } if ( ! $ this -> rootModuleFileManager && $ this -> context instanceof ProjectContext ) { $ this -> rootModuleFileManager = new RootModuleFileManagerImpl ( $ this -> context , $ this -> ge...
Returns the root module file manager .
6,783
public function getModuleManager ( ) { if ( ! $ this -> started ) { throw new LogicException ( 'Puli was not started' ) ; } if ( ! $ this -> moduleManager && $ this -> context instanceof ProjectContext ) { $ this -> moduleManager = new ModuleManagerImpl ( $ this -> context , $ this -> getJsonStorage ( ) ) ; } return $ ...
Returns the module manager .
6,784
public function getRepositoryManager ( ) { if ( ! $ this -> started ) { throw new LogicException ( 'Puli was not started' ) ; } if ( ! $ this -> repositoryManager && $ this -> context instanceof ProjectContext ) { $ this -> repositoryManager = new RepositoryManagerImpl ( $ this -> context , $ this -> getRepository ( ) ...
Returns the resource repository manager .
6,785
public function getDiscoveryManager ( ) { if ( ! $ this -> started ) { throw new LogicException ( 'Puli was not started' ) ; } if ( ! $ this -> discoveryManager && $ this -> context instanceof ProjectContext ) { $ this -> discoveryManager = new DiscoveryManagerImpl ( $ this -> context , $ this -> getDiscovery ( ) , $ t...
Returns the resource discovery manager .
6,786
public function getServerManager ( ) { if ( ! $ this -> started ) { throw new LogicException ( 'Puli was not started' ) ; } if ( ! $ this -> serverManager && $ this -> context instanceof ProjectContext ) { $ this -> serverManager = new ModuleFileServerManager ( $ this -> getRootModuleFileManager ( ) , $ this -> getInst...
Returns the server manager .
6,787
public function getJsonEncoder ( ) { if ( ! $ this -> jsonEncoder ) { $ this -> jsonEncoder = new JsonEncoder ( ) ; $ this -> jsonEncoder -> setPrettyPrinting ( true ) ; $ this -> jsonEncoder -> setEscapeSlash ( false ) ; $ this -> jsonEncoder -> setTerminateWithLineFeed ( true ) ; } return $ this -> jsonEncoder ; }
Returns the JSON encoder .
6,788
public function getJsonValidator ( ) { if ( ! $ this -> jsonValidator ) { $ uriRetriever = new UriRetriever ( ) ; $ uriRetriever -> setUriRetriever ( new LocalUriRetriever ( ) ) ; $ this -> jsonValidator = new JsonValidator ( null , $ uriRetriever ) ; } return $ this -> jsonValidator ; }
Returns the JSON validator .
6,789
private function createProjectContext ( $ rootDir , $ env ) { Assert :: fileExists ( $ rootDir , 'Could not load Puli context: The root %s does not exist.' ) ; Assert :: directory ( $ rootDir , 'Could not load Puli context: The root %s is a file. Expected a directory.' ) ; $ baseConfig = new DefaultConfig ( ) ; $ homeD...
Creates the context of a Puli project .
6,790
private function getJsonStorage ( ) { if ( ! $ this -> jsonStorage ) { $ this -> jsonStorage = new JsonStorage ( $ this -> getStorage ( ) , new JsonConverterProvider ( $ this ) , $ this -> getJsonEncoder ( ) , $ this -> getJsonDecoder ( ) , $ this -> getFactoryManager ( ) ) ; } return $ this -> jsonStorage ; }
Returns the JSON file storage .
6,791
private function getJsonVersioner ( ) { if ( ! $ this -> jsonVersioner ) { $ this -> jsonVersioner = new ChainVersioner ( array ( new SchemaUriVersioner ( ) , new VersionFieldVersioner ( ) , ) ) ; } return $ this -> jsonVersioner ; }
Returns the JSON versioner .
6,792
private function getModuleFileMigrationManager ( ) { if ( ! $ this -> moduleFileMigrationManager ) { $ this -> moduleFileMigrationManager = new MigrationManager ( array ( new ModuleFile10To20Migration ( ) , ) , $ this -> getJsonVersioner ( ) ) ; } return $ this -> moduleFileMigrationManager ; }
Returns the migration manager for module files .
6,793
private function validatePluginClass ( $ pluginClass ) { if ( ! class_exists ( $ pluginClass ) ) { throw new InvalidConfigException ( sprintf ( 'The plugin class %s does not exist.' , $ pluginClass ) ) ; } if ( ! in_array ( 'Puli\Manager\Api\PuliPlugin' , class_implements ( $ pluginClass ) ) ) { throw new InvalidConfig...
Validates the given plugin class name .
6,794
private function getPixel ( $ x , $ y , Color $ color ) { return ( new Rectangle ( $ x * 80 + 40 , $ y * 80 + 40 , 80 , 80 ) ) -> setFillColor ( $ color ) -> setStrokeWidth ( 0 ) ; }
Returns a pixel drawn accordingly to the passed parameters .
6,795
private function showPixel ( $ x , $ y , $ hash ) { return hexdec ( substr ( $ hash , 6 + abs ( 2 - $ x ) * 5 + $ y , 1 ) ) % 2 === 0 ; }
Determines whether a pixel from the 5x5 grid should be visible .
6,796
public static function forModules ( ModuleList $ modules ) { $ graph = new static ( $ modules -> getModuleNames ( ) ) ; foreach ( $ modules as $ module ) { if ( null === $ module -> getModuleFile ( ) ) { continue ; } foreach ( $ module -> getModuleFile ( ) -> getDependencies ( ) as $ dependency ) { if ( $ graph -> hasM...
Creates an override graph for the given modules .
6,797
public function addModuleName ( $ moduleName ) { if ( isset ( $ this -> moduleNames [ $ moduleName ] ) ) { throw new RuntimeException ( sprintf ( 'The module "%s" was added to the graph twice.' , $ moduleName ) ) ; } $ this -> moduleNames [ $ moduleName ] = true ; $ this -> dependencies [ $ moduleName ] = array ( ) ; }
Adds a module name to the graph .
6,798
public function getSortedModuleNames ( array $ namesToSort = array ( ) ) { if ( count ( $ namesToSort ) > 0 ) { $ namesToSort = array_flip ( $ namesToSort ) ; foreach ( $ namesToSort as $ module => $ _ ) { if ( ! isset ( $ this -> moduleNames [ $ module ] ) ) { throw new RuntimeException ( sprintf ( 'The module "%s" do...
Returns the sorted module names .
6,799
public function addDependency ( $ moduleName , $ dependency ) { if ( ! isset ( $ this -> moduleNames [ $ dependency ] ) ) { throw new RuntimeException ( sprintf ( 'The module "%s" does not exist in the graph.' , $ dependency ) ) ; } if ( ! isset ( $ this -> moduleNames [ $ moduleName ] ) ) { throw new RuntimeException ...
Adds a dependency from one to another module .