idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
46,900
public function getDelivery ( Transaction $ transaction = null ) { if ( $ this -> session -> has ( 'delivery-id' ) ) { $ delivery = $ this -> manager -> getRepository ( 'EcommerceBundle:Delivery' ) -> find ( $ this -> session -> get ( 'delivery-id' ) ) ; return $ delivery ; } $ delivery = new Delivery ( ) ; $ billingAddress = $ this -> manager -> getRepository ( 'EcommerceBundle:Address' ) -> findOneBy ( array ( 'actor' => $ this -> securityContext -> getToken ( ) -> getUser ( ) , 'forBilling' => true ) ) ; if ( false === is_null ( $ billingAddress ) ) { $ delivery -> setFullName ( $ this -> securityContext -> getToken ( ) -> getUser ( ) -> getFullName ( ) ) ; $ delivery -> setContactPerson ( $ billingAddress -> getContactPerson ( ) ) ; $ delivery -> setDni ( $ billingAddress -> getDni ( ) ) ; $ delivery -> setAddressInfo ( $ billingAddress -> getAddressInfo ( ) ) ; $ delivery -> setPhone ( $ billingAddress -> getPhone ( ) ) ; $ delivery -> setPhone2 ( $ billingAddress -> getPhone2 ( ) ) ; $ delivery -> setPreferredSchedule ( $ billingAddress -> getPreferredSchedule ( ) ) ; } $ country = $ this -> manager -> getRepository ( 'CoreBundle:Country' ) -> find ( 'es' ) ; $ delivery -> setCountry ( $ country ) ; if ( false === is_null ( $ transaction ) ) { $ delivery -> setTransaction ( $ transaction ) ; } return $ delivery ; }
Build a delivery object for the current actor
46,901
public function saveDelivery ( Delivery $ delivery , array $ params , $ cart ) { if ( 'same' === $ params [ 'selectDelivery' ] ) { $ delivery -> setDeliveryContactPerson ( $ delivery -> getContactPerson ( ) ) ; $ delivery -> setDeliveryDni ( $ delivery -> getDni ( ) ) ; $ delivery -> setDeliveryAddressInfo ( $ delivery -> getAddressInfo ( ) ) ; $ delivery -> setDeliveryPhone ( $ delivery -> getPhone ( ) ) ; $ delivery -> setDeliveryPhone2 ( $ delivery -> getPhone2 ( ) ) ; $ delivery -> setDeliveryPreferredSchedule ( $ delivery -> getPreferredSchedule ( ) ) ; } else if ( 'existing' === $ params [ 'selectDelivery' ] ) { $ address = $ this -> manager -> getRepository ( 'EcommerceBundle:Address' ) -> find ( $ params [ 'existingDeliveryAddress' ] ) ; $ delivery -> setDeliveryContactPerson ( $ address -> getContactPerson ( ) ) ; $ delivery -> setDeliveryDni ( $ address -> getDni ( ) ) ; $ delivery -> setDeliveryAddressInfo ( $ address -> getAddressInfo ( ) ) ; $ delivery -> setDeliveryPhone ( $ address -> getPhone ( ) ) ; $ delivery -> setDeliveryPhone2 ( $ address -> getPhone2 ( ) ) ; $ delivery -> setDeliveryPreferredSchedule ( $ address -> getPreferredSchedule ( ) ) ; } else if ( 'new' === $ params [ 'selectDelivery' ] ) { $ this -> addUserDeliveryAddress ( $ delivery ) ; } $ deliveryCountry = $ this -> manager -> getRepository ( 'CoreBundle:Country' ) -> find ( 'es' ) ; $ delivery -> setDeliveryCountry ( $ deliveryCountry ) ; $ total = 0 ; $ productPurchases = $ this -> manager -> getRepository ( 'EcommerceBundle:ProductPurchase' ) -> findByTransaction ( $ delivery -> getTransaction ( ) ) ; foreach ( $ productPurchases as $ item ) { if ( $ item -> getDeliveryExpenses ( ) > 0 ) $ total = $ total + $ item -> getDeliveryExpenses ( ) ; } $ delivery -> setExpenses ( $ total ) ; if ( $ total > 0 ) $ delivery -> setExpensesType ( 'store_pickup' ) ; else $ delivery -> setExpensesType ( 'send' ) ; $ this -> saveUserBillingAddress ( $ delivery ) ; $ this -> manager -> persist ( $ delivery ) ; $ this -> manager -> flush ( ) ; $ this -> session -> set ( 'delivery-id' , $ delivery -> getId ( ) ) ; $ this -> session -> set ( 'select-delivery' , $ params [ 'selectDelivery' ] ) ; if ( 'existing' === $ params [ 'selectDelivery' ] ) { $ this -> session -> set ( 'existing-delivery-address' , intval ( $ params [ 'existingDeliveryAddress' ] ) ) ; } else { $ this -> session -> remove ( 'existing-delivery-address' ) ; } $ this -> session -> save ( ) ; }
Save delivery fields from billing fields
46,902
private function saveUserBillingAddress ( $ delivery ) { $ billingAddress = $ this -> manager -> getRepository ( 'EcommerceBundle:Address' ) -> findOneBy ( array ( 'actor' => $ this -> securityContext -> getToken ( ) -> getUser ( ) , 'forBilling' => true ) ) ; if ( is_null ( $ billingAddress ) ) { $ billingAddress = new Address ( ) ; $ billingAddress -> setForBilling ( true ) ; $ billingAddress -> setActor ( $ this -> securityContext -> getToken ( ) -> getUser ( ) ) ; } $ billingAddress -> setContactPerson ( $ delivery -> getContactPerson ( ) ) ; $ billingAddress -> setDni ( $ delivery -> getDni ( ) ) ; $ billingAddress -> setAddressInfo ( $ delivery -> getAddressInfo ( ) ) ; $ billingAddress -> setPhone ( $ delivery -> getPhone ( ) ) ; $ billingAddress -> setPhone2 ( $ delivery -> getPhone2 ( ) ) ; $ billingAddress -> setPreferredSchedule ( $ delivery -> getPreferredSchedule ( ) ) ; $ country = $ this -> manager -> getRepository ( 'CoreBundle:Country' ) -> find ( 'es' ) ; $ billingAddress -> setCountry ( $ country ) ; $ this -> manager -> persist ( $ billingAddress ) ; $ this -> manager -> flush ( ) ; }
Save user billing address
46,903
public function cleanSession ( ) { $ this -> session -> remove ( 'select-delivery' ) ; $ this -> session -> remove ( 'delivery-id' ) ; $ this -> session -> remove ( 'existing-delivery-address' ) ; $ this -> session -> remove ( 'transaction-id' ) ; $ this -> cartProvider -> abandonCart ( ) ; }
Clean checkout parameters from session and void the shopping cart
46,904
public function getBillingAddress ( $ actor = null ) { if ( is_null ( $ actor ) ) { $ actor = $ this -> securityContext -> getToken ( ) -> getUser ( ) ; if ( ! $ actor || ! is_object ( $ actor ) ) { throw new \ LogicException ( 'The getBillingAddress cannot be used without an authenticated user!' ) ; } } $ address = $ this -> manager -> getRepository ( 'EcommerceBundle:Address' ) -> findOneBy ( array ( 'actor' => $ actor , 'forBilling' => true ) ) ; if ( is_null ( $ address ) ) { $ address = new Address ( ) ; $ address -> setForBilling ( true ) ; $ country = $ this -> manager -> getRepository ( 'CoreBundle:Country' ) -> find ( 'es' ) ; $ address -> setCountry ( $ country ) ; $ address -> setActor ( $ actor ) ; } return $ address ; }
Get billing address
46,905
public function isCurrentUserOwner ( Transaction $ transaction ) { if ( $ this -> securityContext -> getToken ( ) -> getUser ( ) -> isGranted ( 'ROLE_ADMIN' ) ) { return true ; } $ currentUserId = $ this -> securityContext -> getToken ( ) -> getUser ( ) -> getId ( ) ; if ( $ transaction -> getActor ( ) instanceof Actor ) { if ( $ currentUserId == $ transaction -> getActor ( ) -> getId ( ) ) { return true ; } elseif ( $ currentUserId == $ transaction -> getItems ( ) -> first ( ) -> getProduct ( ) -> getActor ( ) -> getId ( ) ) { return true ; } } return false ; }
Check if current user is the transaction owner
46,906
public function processBankTransfer ( Transaction $ transaction ) { $ transaction -> setStatus ( Transaction :: STATUS_PENDING_TRANSFER ) ; $ pm = $ this -> manager -> getRepository ( 'EcommerceBundle:PaymentMethod' ) -> findOneBySlug ( 'bank-transfer-test' ) ; $ transaction -> setPaymentMethod ( $ pm ) ; $ this -> manager -> persist ( $ transaction ) ; $ this -> manager -> flush ( ) ; return true ; }
Process a bank transfer request
46,907
public function processRedsysTransaction ( $ ds_response , Transaction $ transaction ) { if ( $ ds_response > 99 ) { return false ; } $ transaction -> setStatus ( Transaction :: STATUS_PAID ) ; $ pm = $ this -> manager -> getRepository ( 'EcommerceBundle:PaymentMethod' ) -> findOneBySlug ( 'redsys' ) ; $ transaction -> setPaymentMethod ( $ pm ) ; $ this -> manager -> persist ( $ transaction ) ; $ this -> manager -> flush ( ) ; return true ; }
Process a redsys transaction
46,908
public function get ( string $ name ) : ? ResponseCookieInterface { if ( ! isset ( $ this -> responseCookies [ $ name ] ) ) { return null ; } return $ this -> responseCookies [ $ name ] ; }
Returns the response cookie by name if it exists null otherwise .
46,909
public function set ( string $ name , ResponseCookieInterface $ responseCookie ) : void { $ this -> responseCookies [ $ name ] = $ responseCookie ; }
Sets a response cookie by name .
46,910
private function isLocalIp ( ) { $ ip = $ this -> serverData [ "REMOTE_ADDR" ] ; if ( ! is_string ( $ ip ) ) { return false ; } if ( in_array ( $ ip , [ '127.0.0.1' , 'fe80::1' , '::1' ] , true ) ) { return true ; } return 1 === preg_match ( "/^(10\\.|192\\.168\\.|172\\.(1[6-9]|2[0-9]|3[0-1])\\.)/" , $ ip ) ; }
Returns whether remote IP is a local one
46,911
public function serialize ( $ serializablePage , $ format ) { if ( ! SerpPageSerializerHelper :: validFormat ( $ format , self :: $ supportedFormatSerialization ) ) throw new \ Franzip \ SerpPageSerializer \ Exceptions \ UnsupportedSerializationFormatException ( 'Invalid SerpPageSerializer $format: supported serialization formats are JSON, XML and YAML.' ) ; if ( ! SerpPageSerializerHelper :: serializablePage ( $ serializablePage ) ) throw new \ Franzip \ SerpPageSerializer \ Exceptions \ NonSerializableObjectException ( 'Invalid SerpPageSerializer $serializablePage: you must supply a SerializableSerpPage object to serialize.' ) ; $ format = strtolower ( $ format ) ; $ entries = $ this -> createEntries ( $ serializablePage , $ format ) ; $ serializablePage = $ this -> prepareForSerialization ( $ serializablePage , $ format , $ entries ) ; $ serializedPage = $ this -> getSerializer ( ) -> serialize ( $ serializablePage , $ format ) ; $ content = ( $ format == 'json' ) ? SerpPageSerializerHelper :: prettyJSON ( $ serializedPage ) : $ serializedPage ; return new SerializedSerpPage ( $ content ) ; }
Serialize a SerializableSerpPage object in the target format
46,912
public function deserialize ( $ serializedPage , $ format ) { if ( ! SerpPageSerializerHelper :: validFormat ( $ format , self :: $ supportedFormatDeserialization ) ) throw new \ Franzip \ SerpPageSerializer \ Exceptions \ UnsupportedDeserializationFormatException ( 'Invalid SerpPageSerializer $format: supported deserialization formats are JSON and XML.' ) ; if ( ! SerpPageSerializerHelper :: deserializablePage ( $ serializedPage ) ) throw new \ Franzip \ SerpPageSerializer \ Exceptions \ RuntimeException ( 'Invalid SerpPageSerializer $serializedPage: you must supply a SerializedSerpPage object to deserialize.' ) ; $ format = strtolower ( $ format ) ; $ targetClass = self :: SERIALIZABLE_OBJECT_PREFIX . strtoupper ( $ format ) ; return $ this -> getSerializer ( ) -> deserialize ( $ serializedPage -> getContent ( ) , $ targetClass , $ format ) ; }
Deserialize a serialized page . YAML deserialization is not currently supported .
46,913
private function prepareForSerialization ( $ serializablePage , $ format , $ entries ) { $ engine = $ serializablePage -> getEngine ( ) ; $ keyword = $ serializablePage -> getKeyword ( ) ; $ pageUrl = $ serializablePage -> getPageUrl ( ) ; $ pageNumber = $ serializablePage -> getPageNumber ( ) ; $ age = $ serializablePage -> getAge ( ) ; return self :: getFormatClassName ( $ format , array ( $ engine , $ pageNumber , $ pageUrl , $ keyword , $ age , $ entries ) ) ; }
Map SerializableSerpPage to an easy serializable SerpPage . The serialization format is resolved at runtime .
46,914
private function createEntries ( $ serializablePage , $ format ) { $ result = array ( ) ; $ entries = $ serializablePage -> getEntries ( ) ; for ( $ i = 0 ; $ i < count ( $ entries ) ; $ i ++ ) { $ args = array ( ( $ i + 1 ) , $ entries [ $ i ] [ 'url' ] , $ entries [ $ i ] [ 'title' ] , $ entries [ $ i ] [ 'snippet' ] ) ; array_push ( $ result , self :: getFormatClassName ( $ format , $ args , true ) ) ; } return $ result ; }
Map SerializableSerpPage entries to SerpPageEntries . The serialization format is resolved at runtime .
46,915
public function setJobName ( $ name ) { if ( ! is_string ( $ name ) ) { throw new InvalidArgumentException ( 'Job name must be a string' ) ; } $ name = trim ( $ name ) ; $ strlen = mb_strlen ( $ name ) ; if ( ! $ strlen ) { throw new InvalidArgumentException ( 'Job name cannot be empty' ) ; } elseif ( $ strlen < 2 || $ strlen > 255 ) { throw new InvalidArgumentException ( 'Job name length must be in range 2-255 characters' ) ; } $ this -> jobName = $ name ; return $ this ; }
Set job name
46,916
public function setPayload ( $ data ) { if ( ! is_string ( $ data ) ) { if ( is_array ( $ data ) ) { $ data = json_encode ( $ data , JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ; } else { $ data = serialize ( $ data ) ; } } $ maxLength = 255 ; if ( mb_strlen ( $ data ) > $ maxLength ) { $ data = mb_substr ( $ data , 0 , $ maxLength - 3 ) . '...' ; } $ this -> payload = $ data ? $ data : null ; return $ this ; }
Set payload value
46,917
public function setDuration ( $ seconds ) { $ seconds = round ( $ seconds , 3 ) ; if ( $ seconds < 0 || $ seconds > 999999.999 ) { throw new InvalidArgumentException ( 'Duration seconds must be in range 0-999999.999' ) ; } $ this -> duration = $ seconds ; return $ this ; }
Set custom duration value
46,918
public function round ( int $ precision = 0 , ? RoundingMode $ roundingMode = null ) : FloatObject { if ( $ roundingMode === null ) { $ roundingMode = RoundingMode :: HALF_UP ( ) ; } return new static ( ( float ) round ( $ this -> value , $ precision , $ roundingMode -> value ( ) ) ) ; }
Creates a float that represents the rounded value
46,919
public function setModel ( $ model ) { $ this -> model = $ model ; $ this -> from ( $ this -> model -> metableTable ( ) . ' AS m' ) ; if ( $ this -> model -> metableTableSoftDeletes ( ) ) { $ this -> whereNull ( 'm.' . $ this -> model -> getDeletedAtColumn ( ) ) ; } return $ this ; }
Set the model for this instance .
46,920
public function whereAnyMetaId ( array $ metas ) { $ filters = array ( ) ; foreach ( $ metas as $ meta => $ data ) { $ value = is_array ( $ data ) ? Arr :: get ( $ data , 0 ) : $ data ; $ operator = is_array ( $ data ) ? Arr :: get ( $ data , 1 , '=' ) : '=' ; $ filters [ ] = array ( 'id' => $ meta , 'value' => $ value , 'operator' => $ operator ) ; } $ this -> filters [ ] [ 'metas' ] = $ filters ; return $ this ; }
Filter the query on any of the given meta ids and meta values .
46,921
public function encode ( $ string ) { if ( empty ( $ string ) || empty ( $ this -> key ) ) { throw new \ Exception ( "Can not encrypt with an empty key or no data" ) ; return false ; } $ publicKey = $ this -> generateKey ( $ string ) ; $ privateKey = $ this -> key ; $ hashKey = sha1 ( $ privateKey . "+" . ( string ) $ publicKey ) ; $ stringArray = str_split ( $ string ) ; $ hashArray = str_split ( $ hashKey ) ; $ cipherNoise = str_split ( $ publicKey , 2 ) ; $ counter = 0 ; for ( $ i = 0 ; $ i < sizeof ( $ stringArray ) ; $ i ++ ) { if ( $ counter > 40 ) $ counter = 0 ; $ cryptChar = ord ( ( string ) $ stringArray [ $ i ] ) + ord ( ( string ) $ hashArray [ $ counter ] ) ; $ cryptChar -= floor ( $ cryptChar / 127 ) * 127 ; $ cipherStream [ $ i ] = dechex ( $ cryptChar ) ; $ counter ++ ; } $ cipherNoiseSize = count ( $ cipherNoise ) ; $ cipher = implode ( "|x" , $ cipherStream ) ; $ cipher .= "|x::|x" . ord ( ( string ) $ cipherNoiseSize ) . "|x" ; $ cipher .= implode ( "|x" , $ cipherNoise ) ; return $ cipher ; }
Encodes a given string
46,922
public static function generateKey ( $ txt , $ length = null ) { date_default_timezone_set ( 'UTC' ) ; $ possible = "2346789bcdfghjkmnpqrtvwxyzBCDFGHJKLMNPQRTVWXYZ" ; $ maxlength = ( empty ( $ length ) || ( int ) $ length > strlen ( $ possible ) ) ? strlen ( $ possible ) : ( int ) $ length ; $ random = "" ; $ i = 0 ; while ( $ i < ( $ maxlength / 5 ) ) { $ char = substr ( $ possible , mt_rand ( 0 , $ maxlength - 1 ) , 1 ) ; if ( ! strstr ( $ random , $ char ) ) { $ random .= $ char ; $ i ++ ; } } $ salt = time ( ) . $ random ; $ rand = mt_rand ( ) ; $ key = md5 ( $ rand . $ txt . $ salt ) ; return $ key ; }
Generates a random encryption key
46,923
public function decode ( $ encrypted ) { $ blocks = explode ( "|x" , $ encrypted ) ; $ delimiter = array_search ( "::" , $ blocks ) ; $ cipherStream = array_slice ( $ blocks , 0 , ( int ) $ delimiter ) ; unset ( $ blocks [ ( int ) $ delimiter ] ) ; unset ( $ blocks [ ( int ) $ delimiter + 1 ] ) ; $ publicKeyArray = array_slice ( $ blocks , ( int ) $ delimiter ) ; $ publicKey = implode ( '' , $ publicKeyArray ) ; $ privateKey = $ this -> key ; $ hashKey = sha1 ( $ privateKey . "+" . ( string ) $ publicKey ) ; $ hashArray = str_split ( $ hashKey ) ; $ counter = 0 ; for ( $ i = 0 ; $ i < sizeof ( $ cipherStream ) ; $ i ++ ) { if ( $ counter > 40 ) $ counter = 0 ; $ cryptChar = hexdec ( $ cipherStream [ $ i ] ) - ord ( ( string ) $ hashArray [ $ counter ] ) ; $ cryptChar -= floor ( $ cryptChar / 127 ) * 127 ; $ cipherText [ $ i ] = chr ( $ cryptChar ) ; $ counter ++ ; } $ plaintext = implode ( "" , $ cipherText ) ; return $ plaintext ; }
Decodes a previously encode string .
46,924
public function send ( MessageInterface $ message , $ target ) { $ msg = $ message -> getMessageString ( ) ; if ( strpos ( $ target , ':' ) ) { list ( $ host , $ port ) = explode ( ':' , $ target ) ; } else { $ host = $ target ; $ port = self :: DEFAULT_UDP_PORT ; } $ sock = socket_create ( AF_INET , SOCK_DGRAM , SOL_UDP ) ; if ( $ sock === false ) { $ errorCode = socket_last_error ( ) ; $ errorMsg = socket_strerror ( $ errorCode ) ; throw new \ RuntimeException ( "Error creating socket: [$errorCode] $errorMsg" ) ; } socket_sendto ( $ sock , $ msg , strlen ( $ msg ) , 0 , $ host , $ port ) ; socket_close ( $ sock ) ; }
Send the syslog to target host using the UDP protocol . Note that the UDP protocol is stateless which means we can t confirm that the message was received by the other end
46,925
private static function getMainJsFileName ( string $ realPath ) : string { $ parts = pathinfo ( $ realPath ) ; return $ parts [ 'dirname' ] . '/' . $ parts [ 'filename' ] . '.main.' . $ parts [ 'extension' ] ; }
Returns the main file of a page specific main JavaScript file .
46,926
protected function minimizeResource ( string $ resource , ? string $ fullPathName ) : string { list ( $ std_out , $ std_err ) = $ this -> runProcess ( $ this -> minifyCommand , $ resource ) ; if ( $ std_err ) $ this -> logInfo ( $ std_err ) ; return $ std_out ; }
Minimizes JavaScript code .
46,927
private function combine ( string $ realPath ) : array { $ config = $ this -> extractConfigFromMainFile ( self :: getMainJsFileName ( $ realPath ) ) ; $ tmp_name1 = tempnam ( '.' , 'abc_' ) ; $ handle = fopen ( $ tmp_name1 , 'w' ) ; fwrite ( $ handle , $ config ) ; fclose ( $ handle ) ; $ tmp_name2 = tempnam ( $ this -> resourceDirFullPath , 'abc_' ) ; $ command = [ $ this -> combineCommand , '-o' , $ tmp_name1 , 'baseUrl=' . $ this -> resourceDirFullPath , 'optimize=none' , 'name=' . $ this -> getNamespaceFromResourceFilename ( $ realPath ) , 'out=' . $ tmp_name2 ] ; $ output = $ this -> execCommand ( $ command ) ; $ parts = [ ] ; $ trigger = array_search ( '----------------' , $ output ) ; foreach ( $ output as $ index => $ file ) { if ( $ index > $ trigger && ! empty ( $ file ) ) { $ parts [ ] = $ file ; } } $ code = file_get_contents ( $ tmp_name2 ) ; if ( $ code === false ) $ this -> logError ( "Unable to read file '%s'." , $ tmp_name2 ) ; $ path = $ this -> parentResourceDirFullPath . '/' . $ this -> requireJsPath ; $ require_js = file_get_contents ( $ path ) ; if ( $ code === false ) $ this -> logError ( "Unable to read file '%s'." , $ path ) ; $ code = $ require_js . $ code ; unlink ( $ tmp_name2 ) ; unlink ( $ tmp_name1 ) ; return [ 'code' => $ code , 'parts' => $ parts ] ; }
Combines all JavaScript files required by a main JavaScript file .
46,928
private function execCommand ( array $ command ) : array { $ this -> logVerbose ( 'Execute: %s' , implode ( ' ' , $ command ) ) ; list ( $ output , $ ret ) = ProgramExecution :: exec1 ( $ command , null ) ; if ( $ ret != 0 ) { foreach ( $ output as $ line ) { $ this -> logInfo ( $ line ) ; } $ this -> logError ( "Error executing '%s'." , implode ( ' ' , $ command ) ) ; } else { foreach ( $ output as $ line ) { $ this -> logVerbose ( $ line ) ; } } return $ output ; }
Executes an external program .
46,929
private function extractPaths ( string $ mainJsFile ) : array { $ command = [ $ this -> nodePath , __DIR__ . '/../../lib/extract_config.js' , $ mainJsFile ] ; $ output = $ this -> execCommand ( $ command ) ; $ config = json_decode ( implode ( PHP_EOL , $ output ) , true ) ; return [ $ config [ 'baseUrl' ] , $ config [ 'paths' ] ] ; }
Reads the main . js file and returns baseUrl and paths .
46,930
private function getFullPathFromClassName ( string $ className ) : string { $ file_name = str_replace ( '\\' , '/' , $ className ) . $ this -> extension ; $ full_path = $ this -> resourceDirFullPath . '/' . $ file_name ; return $ full_path ; }
Returns the full path of a ADM JavaScript file based on a PHP class name .
46,931
private function getFullPathFromNamespace ( string $ namespace ) : string { $ file_name = $ namespace . $ this -> extension ; $ full_path = $ this -> resourceDirFullPath . '/' . $ file_name ; return $ full_path ; }
Returns the full path of a ADM JavaScript file based on a ADM namespace .
46,932
private function getMainWithHashedPaths ( string $ realPath ) : string { $ main_js_file = self :: getMainJsFileName ( $ realPath ) ; $ js = file_get_contents ( $ main_js_file ) ; if ( $ js === false ) $ this -> logError ( "Unable to read file '%s'." , $ realPath ) ; preg_match ( '/^(.*paths:[^{]*)({[^}]*})(.*)$/sm' , $ js , $ matches ) ; if ( ! isset ( $ matches [ 2 ] ) ) $ this -> logError ( "Unable to find paths in '%s'." , $ realPath ) ; $ paths = [ ] ; list ( $ base_url , $ aliases ) = $ this -> extractPaths ( $ main_js_file ) ; if ( isset ( $ base_url ) && isset ( $ paths ) ) { foreach ( $ aliases as $ alias => $ path ) { $ path_with_hash = $ this -> getPathInResourcesWithHash ( $ base_url , $ path ) ; if ( isset ( $ path_with_hash ) ) { $ paths [ $ this -> removeJsExtension ( $ path_with_hash ) ] = $ alias ; } } } foreach ( $ this -> getResourcesInfo ( ) as $ info ) { if ( ! isset ( $ paths [ $ this -> removeJsExtension ( $ info [ 'path_name_in_sources_with_hash' ] ) ] ) ) { if ( isset ( $ info [ 'path_name_in_sources' ] ) ) { $ module = $ this -> getNamespaceFromResourceFilename ( $ info [ 'full_path_name' ] ) ; $ path_with_hash = $ this -> getNamespaceFromResourceFilename ( $ info [ 'full_path_name_with_hash' ] ) ; $ paths [ $ path_with_hash ] = $ module ; } } } $ matches [ 2 ] = json_encode ( array_flip ( $ paths ) , JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ) ; array_shift ( $ matches ) ; $ js = implode ( '' , $ matches ) ; return $ js ; }
Rewrites paths in requirejs . config . Adds path names from namespaces and aliases to filenames with hashes .
46,933
private function getNamespaceFromResourceFilename ( string $ resourceFilename ) : string { $ name = $ this -> getPathInResources ( $ resourceFilename ) ; $ len = strlen ( trim ( $ this -> resourceDir , '/' ) ) ; if ( $ len > 0 ) { $ name = substr ( $ name , $ len + 2 ) ; } $ parts = pathinfo ( $ name ) ; $ name = substr ( $ name , 0 , - ( strlen ( $ parts [ 'extension' ] ) + 1 ) ) ; return $ name ; }
Returns the namespace based on the name of a JavaScript file .
46,934
private function FetchFields ( $ parent ) { $ child = $ this -> tree -> FirstChildOf ( $ parent ) ; while ( $ child ) { $ this -> HandleField ( $ child ) ; $ this -> FetchFields ( $ child ) ; $ child = $ this -> tree -> NextOf ( $ child ) ; } }
Fetches all form field content elements and adds it to this form in an appropriate manner
46,935
private function SaveToTable ( $ table ) { $ sql = Access :: SqlBuilder ( ) ; $ fields = array ( ) ; $ setList = null ; foreach ( $ this -> Elements ( ) -> GetElements ( ) as $ element ) { $ this -> HandleElement ( $ table , $ element , $ fields , $ setList ) ; } if ( $ setList ) { Access :: Connection ( ) -> ExecuteQuery ( $ sql -> Insert ( $ sql -> Table ( $ table , $ fields ) , $ setList ) ) ; } }
Stores the results in a database table
46,936
public function prepareSentryPermissionInput ( array & $ input , $ operation , $ field_name = "permissions" ) { $ input [ $ field_name ] = isset ( $ input [ $ field_name ] ) ? [ $ input [ $ field_name ] => $ operation ] : '' ; }
Prepares permission for sentry given the input
46,937
public function jsonSerialize ( ) { $ ret = new StdClass ; foreach ( $ this -> map as $ key => $ value ) { $ ret -> $ key = ( bool ) ( $ this -> source & $ value ) ; } return $ ret ; }
Export this bitflag as a Json object . All known bits are exported as properties with true or false depending on their status .
46,938
public function autoload ( $ class ) { $ isFallback = $ this -> isFallbackAutoloader ( ) ; if ( false !== strpos ( $ class , self :: NS_SEPARATOR ) ) { if ( $ this -> loadClass ( $ class , self :: LOAD_NS ) ) { return $ class ; } elseif ( $ isFallback ) { return $ this -> loadClass ( $ class , self :: ACT_AS_FALLBACK ) ; } return false ; } if ( false !== strpos ( $ class , self :: PREFIX_SEPARATOR ) ) { if ( $ this -> loadClass ( $ class , self :: LOAD_PREFIX ) ) { return $ class ; } elseif ( $ isFallback ) { return $ this -> loadClass ( $ class , self :: ACT_AS_FALLBACK ) ; } return false ; } if ( $ isFallback ) { return $ this -> loadClass ( $ class , self :: ACT_AS_FALLBACK ) ; } return false ; }
Defined by Autoloadable ; autoload a class
46,939
protected function transformClassNameToFilename ( $ class , $ directory ) { $ matches = array ( ) ; preg_match ( '/(?P<namespace>.+\\\)?(?P<class>[^\\\]+$)/' , $ class , $ matches ) ; $ class = ( isset ( $ matches [ 'class' ] ) ) ? $ matches [ 'class' ] : '' ; $ namespace = ( isset ( $ matches [ 'namespace' ] ) ) ? $ matches [ 'namespace' ] : '' ; return $ directory . str_replace ( self :: NS_SEPARATOR , '/' , $ namespace ) . str_replace ( self :: PREFIX_SEPARATOR , '/' , $ class ) . '.php' ; }
Transform the class name to a filename
46,940
protected function normalizeDirectory ( $ directory ) { $ last = $ directory [ strlen ( $ directory ) - 1 ] ; if ( in_array ( $ last , array ( '/' , '\\' ) ) ) { $ directory [ strlen ( $ directory ) - 1 ] = DIRECTORY_SEPARATOR ; return $ directory ; } $ directory .= DIRECTORY_SEPARATOR ; return $ directory ; }
Normalize the directory to include a trailing directory separator
46,941
public function addResource ( $ resource , $ prefix = null ) { $ this -> resources [ ] = [ $ resource , $ prefix , true ] ; return $ this ; }
Add a resource to load configuration values from .
46,942
public function addOptionalResource ( $ resource , $ prefix = null ) { $ this -> resources [ ] = [ $ resource , $ prefix , false ] ; return $ this ; }
Add an optional resource to load configuration values from .
46,943
protected function loadResource ( $ resource , $ required ) { foreach ( $ this -> loaders as $ loader ) { if ( ! $ loader -> supports ( $ resource ) ) { continue ; } try { return $ loader -> load ( $ resource ) ; } catch ( ResourceNotFoundException $ e ) { if ( $ required ) { throw $ e ; } return [ ] ; } } throw new ResourceException ( sprintf ( 'There is no configuration loader available to load the resource "%s"' , $ resource ) ) ; }
Load a resource using a loader . The first loader that supports the resource will be used .
46,944
public function getConfig ( Schema $ schema = null ) { if ( ! $ schema ) { $ schema = new Schema ( ) ; } $ config = new Config ( ) ; foreach ( $ this -> resources as $ resource ) { $ values = $ this -> loadResource ( $ resource [ 0 ] , $ resource [ 2 ] ) ; if ( is_string ( $ prefix = $ resource [ 1 ] ) ) { $ values = [ $ prefix => $ values , ] ; } $ config -> merge ( $ values ) ; } foreach ( $ this -> processors as $ processor ) { $ processor -> onPostMerge ( $ config , $ schema ) ; } return $ config ; }
Get the resolved configuration .
46,945
private function templateFile ( $ name ) { $ filename = $ this -> viewPath . '/' . str_replace ( '.' , DIRECTORY_SEPARATOR , $ name ) . '.blade.php' ; if ( file_exists ( $ filename ) ) { return $ filename ; } if ( self :: $ manifest === null ) { if ( file_exists ( $ this -> pluginManifestOfViews ) ) { self :: $ manifest = include $ this -> pluginManifestOfViews ; } } return isset ( self :: $ manifest [ $ name ] ) ? base_path ( self :: $ manifest [ $ name ] ) : null ; }
Get the full template filename by given view name .
46,946
private function isCacheUpToDate ( $ cachedFile , $ templateFile ) { if ( ! file_exists ( $ cachedFile ) ) { return false ; } $ cacheTime = filemtime ( $ cachedFile ) ; $ templTime = filemtime ( $ templateFile ) ; return $ cacheTime == $ templTime ; }
Determine if the cached file is up to date with the template .
46,947
private function saveFile ( $ file , $ content , $ time ) { if ( ! is_dir ( $ dir = dirname ( $ file ) ) ) { if ( ! make_dir ( $ dir , 0775 ) ) { throw new RuntimeException ( sprintf ( 'View Template Engine was not able to create directory "%s"' , $ dir ) ) ; } } if ( file_exists ( $ file ) ) { unlink ( $ file ) ; } if ( file_put_contents ( $ file , $ content , LOCK_EX ) === false ) { throw new RuntimeException ( sprintf ( 'View Template Engine was not able to save file "%s"' , $ file ) ) ; } @ chmod ( $ file , 0664 ) ; if ( ! @ touch ( $ file , $ time ) ) { throw new RuntimeException ( sprintf ( 'View Template Engine was not able to modify time of file "%s"' , $ file ) ) ; } }
Save the given content .
46,948
private function storeSection ( $ section , $ content ) { if ( ! isset ( $ this -> scope -> sections [ $ section ] ) ) { $ this -> scope -> sections [ $ section ] = $ content ; } }
Store section .
46,949
public static function Read ( string $ file , string $ message = null , int $ code = \ E_USER_ERROR , \ Throwable $ previous = null ) : FileAccessException { return new FileAccessException ( $ file , FileAccessException :: ACCESS_READ , $ message , $ code , $ previous ) ; }
Init s a new \ Niirrty \ IO \ FileAccessException for file read mode .
46,950
public static function Write ( string $ file , string $ message = null , int $ code = \ E_USER_ERROR , \ Throwable $ previous = null ) : FileAccessException { return new FileAccessException ( $ file , FileAccessException :: ACCESS_WRITE , $ message , $ code , $ previous ) ; }
Init s a new \ UK \ IO \ FileAccessException for file write mode .
46,951
public function runAssets ( $ pageSlug , $ isShortcode = false ) { $ cssList = $ this -> css ; $ jsList = $ this -> js ; MbWPActionHook :: addActionCallback ( $ this -> getActionEnqueue ( ) , function ( ) use ( $ pageSlug , $ cssList , $ jsList ) { foreach ( $ cssList as $ i => $ css ) { wp_enqueue_style ( "style_mb_{$pageSlug}_{$i}" , $ css ) ; } foreach ( $ jsList as $ i => $ js ) { wp_enqueue_script ( "script_mb_{$pageSlug}_{$i}" , $ js [ 'path' ] , [ ] , $ js [ 'version' ] , $ js [ 'footer' ] ) ; } } ) ; if ( $ isShortcode ) { MbWPActionHook :: doAction ( $ this -> getActionEnqueue ( ) ) ; } }
Send assets to wordpress
46,952
protected function autoEnqueue ( ) { $ request = MocaBonita :: getInstance ( ) -> getMbRequest ( ) ; if ( $ request -> isLoginPage ( ) ) { $ this -> actionEnqueue = "login_enqueue_scripts" ; } elseif ( $ request -> isAdmin ( ) ) { $ this -> actionEnqueue = "admin_enqueue_scripts" ; } else { $ this -> actionEnqueue = "wp_enqueue_scripts" ; } }
Auto Enqueue to wordpress
46,953
public function setActionEnqueue ( $ typePage ) { switch ( $ typePage ) { case 'admin' : $ this -> actionEnqueue = "admin_enqueue_scripts" ; break ; case 'login' : $ this -> actionEnqueue = "login_enqueue_scripts" ; break ; default : $ this -> actionEnqueue = "wp_enqueue_scripts" ; break ; } return $ this ; }
Set a type of enqueue
46,954
public function create ( $ type , $ host , $ port , $ database , $ user , $ password ) { return new PDO ( sprintf ( '%s:host=%s;port=%s;dbname=%s' , $ type , $ host , $ port , $ database ) , $ user , $ password ) ; }
Create PDO connection .
46,955
public function addHeaders ( array $ headers ) { foreach ( $ headers as $ key => $ value ) { $ header = NULL ; if ( is_numeric ( $ key ) && strpos ( $ value , ":" ) !== FALSE ) { $ arr = explode ( ":" , $ value , 2 ) ; if ( count ( $ arr ) == 2 ) { $ header = $ arr [ 0 ] ; $ value = trim ( $ arr [ 1 ] ) ; } } else { $ header = $ key ; } if ( $ header !== NULL ) { $ this -> addHeader ( $ header , $ value ) ; } } return $ this ; }
Add multiple headers via an array
46,956
private function compileOptions ( ) { $ this -> CurlOptions = array ( ) ; $ this -> configureHTTPMethod ( $ this -> method ) ; $ this -> configureUrl ( $ this -> url ) ; $ this -> configureBody ( $ this -> body ) ; $ this -> configureHeaders ( $ this -> headers ) ; $ this -> configureOptions ( $ this -> options ) ; return $ this ; }
Actually initialize the cURL Resource and configure All options
46,957
protected function configureHTTPMethod ( $ method ) { switch ( $ method ) { case self :: HTTP_GET : break ; case self :: HTTP_POST : return $ this -> addCurlOption ( CURLOPT_POST , TRUE ) ; default : return $ this -> addCurlOption ( CURLOPT_CUSTOMREQUEST , $ method ) ; } return TRUE ; }
Configure the Curl Options based for a specific HTTP Method
46,958
protected function configureHeaders ( array $ headers ) { $ configuredHeaders = array ( ) ; foreach ( $ headers as $ header => $ value ) { $ configuredHeaders [ ] = "$header: $value" ; } return $ this -> addCurlOption ( CURLOPT_HTTPHEADER , $ configuredHeaders ) ; }
Configure the Headers by setting the CURLOPT_HTTPHEADER Option
46,959
protected function configureBody ( $ body ) { $ upload = $ this -> getUpload ( ) ; switch ( $ this -> method ) { case self :: HTTP_GET : if ( ! $ upload ) { if ( is_array ( $ body ) || is_object ( $ body ) ) { $ queryParams = http_build_query ( $ body ) ; } else { $ queryParams = $ body ; } if ( ! empty ( $ body ) ) { if ( strpos ( $ this -> url , "?" ) === false ) { $ queryParams = "?" . $ queryParams ; } else { $ queryParams = "&" . $ queryParams ; } return $ this -> configureUrl ( $ this -> url . $ queryParams ) ; } break ; } default : if ( $ upload ) { $ this -> addHeader ( 'Content-Type' , 'multipart/form-data' ) ; } return $ this -> addCurlOption ( CURLOPT_POSTFIELDS , $ body ) ; } }
Configure the Body to be set on the cURL Resource
46,960
protected function init ( ) { $ this -> setMethod ( static :: $ _DEFAULT_HTTP_METHOD ) ; $ this -> setHeaders ( static :: $ _DEFAULT_HEADERS ) ; $ this -> setOptions ( static :: $ _DEFAULT_OPTIONS ) ; $ this -> body = NULL ; $ this -> error = NULL ; $ this -> status = self :: STATUS_INIT ; if ( self :: $ _AUTO_INIT ) { return $ this -> initCurl ( ) ; } return TRUE ; }
Initialize the Request Object setting defaults for certain properties
46,961
private function configureCurl ( ) { foreach ( $ this -> getCurlOptions ( ) as $ option => $ value ) { curl_setopt ( $ this -> CurlRequest , $ option , $ value ) ; } return TRUE ; }
Loop through CurlOptions and use curl_setopt to set options on cURL Resource
46,962
private function executeCurl ( ) { if ( $ this -> initCurl ( ) ) { $ this -> configureCurl ( ) ; $ this -> CurlResponse = curl_exec ( $ this -> CurlRequest ) ; $ this -> checkForError ( ) ; return TRUE ; } return FALSE ; }
Execute Curl Resource and set the Curl Response
46,963
private function checkForError ( ) { $ curlErrNo = curl_errno ( $ this -> CurlRequest ) ; if ( $ curlErrNo !== CURLE_OK ) { $ this -> error = TRUE ; $ this -> CurlError = array ( 'error' => $ curlErrNo , 'error_message' => curl_error ( $ this -> CurlRequest ) ) ; } }
Check cURL Resource for Errors and add them to CurlError property if so
46,964
public function setFile ( $ filePath = '.gitignore' ) { $ this -> fileContent = array ( ) ; $ this -> afterLine = null ; $ this -> filePath = $ filePath ; $ this -> checkPermissions ( ) ; $ this -> parse ( ) ; }
Sets the file
46,965
public function setLines ( $ lines ) { if ( ! is_array ( $ lines ) ) { $ this -> lines = array ( $ lines ) ; } else { $ this -> lines = $ lines ; } return $ this ; }
Set the paths to write in . gitignore file
46,966
public static function isAbsolute ( $ path ) { return ( ( isset ( $ path [ 0 ] ) ? ( $ path [ 0 ] == '/' || ( ctype_alpha ( $ path [ 0 ] ) && ( $ path [ 1 ] == ':' ) ) ) : '' ) || ( parse_url ( $ path , PHP_URL_SCHEME ) === true ) ) ? true : false ; }
Checks if a path is an absolute path
46,967
public static function getMime ( $ file ) { $ fileInfo = finfo_open ( FILEINFO_MIME_TYPE ) ; $ mime = finfo_file ( $ fileInfo , $ file ) ; return empty ( $ mime ) ? : $ mime ; }
Gets the mime of a file
46,968
public function render ( ) : Image { $ ftbbox = imageftbbox ( $ this -> fontSize , 0 , $ this -> fontFile , $ this -> text , $ this -> extraInfo ) ; $ width = max ( $ ftbbox [ 2 ] - $ ftbbox [ 6 ] , 1 ) ; $ height = max ( $ ftbbox [ 3 ] - $ ftbbox [ 7 ] , 1 ) ; $ ftbbox = imageftbbox ( $ this -> fontSize , 0 , $ this -> fontFile , $ this -> text [ 0 ] ?? '' , $ this -> extraInfo ) ; $ offset = $ ftbbox [ 3 ] - $ ftbbox [ 7 ] ; $ image = Utility :: transparentImage ( $ width , $ height ) ; imagefttext ( $ image -> getResource ( ) , $ this -> fontSize , 0 , 0 , $ offset , $ this -> color -> allocate ( $ image -> getResource ( ) ) , $ this -> fontFile , $ this -> text , $ this -> extraInfo ) ; return $ image ; }
Renders object as an image .
46,969
public function check ( $ token ) { $ blacklistedToken = $ this -> model -> where ( 'user_id' , $ this -> Token -> getSubject ( $ token ) ) -> where ( 'expiry' , '>' , Carbon :: now ( ) ) -> whereToken ( $ token ) -> first ( ) ; if ( $ blacklistedToken === null ) { return true ; } throw new BlacklistedTokenException ( ) ; }
Check if a given token is considered blacklisted
46,970
public function findByToken ( $ token ) { $ blacklistedToken = $ this -> model -> whereToken ( $ token ) -> first ( ) ; if ( $ blacklistedToken === null ) { throw new ModelNotFoundException ( ) ; } return $ blacklistedToken -> toArray ( ) ; }
Try to find a blacklisted token entity by its associated token
46,971
public function findAllExpired ( ) { $ expiredBlacklistedTokens = $ this -> model -> where ( 'expiry' , '<' , Carbon :: now ( ) ) -> get ( ) ; return $ expiredBlacklistedTokens -> toArray ( ) ; }
Find all blacklisted tokens that have naturally expired and so no longer need to be tracked
46,972
public function deleteAllExpired ( ) { $ expiredBlacklistedTokens = $ this -> findAllExpired ( ) ; foreach ( $ expiredBlacklistedTokens as $ expiredBlacklistedToken ) { $ this -> delete ( $ expiredBlacklistedToken [ 'id' ] ) ; } }
Delete all blacklisted token entities where the associated token has naturally expired and so no longer needs to be tracked
46,973
public function updateCollection ( EntityChangeEventInterface $ event ) { $ collection = $ event -> getCollection ( ) ; if ( $ collection -> getId ( ) ) { $ collectionMap = $ this -> getCollectionsMap ( ) ; $ collectionMap -> set ( $ collection -> getId ( ) , $ collection ) ; } }
Handles collection add event and updates the cache
46,974
protected function query ( Select $ sql ) { $ cid = $ this -> getId ( $ sql ) ; $ collection = $ this -> repository -> getCollectionsMap ( ) -> get ( $ cid , false ) ; if ( false === $ collection ) { $ collection = $ this -> getCollection ( $ sql , $ cid ) ; } return $ collection ; }
Execute provided query
46,975
protected function getCollection ( Select $ sql , $ cid ) { $ this -> triggerBeforeSelect ( $ sql , $ this -> getRepository ( ) -> getEntityDescriptor ( ) ) ; $ data = $ this -> adapter -> query ( $ sql , $ sql -> getParameters ( ) ) ; $ collection = $ this -> repository -> getEntityMapper ( ) -> createFrom ( $ data ) ; $ this -> triggerAfterSelect ( $ data , $ collection ) ; $ this -> registerEventsTo ( $ collection , $ cid ) ; $ this -> getCollectionsMap ( ) -> set ( $ cid , $ collection ) ; $ this -> updateIdentityMap ( $ collection ) ; return $ collection ; }
Executes the provided query
46,976
protected function getCollectionsMap ( ) { if ( null == $ this -> collectionsMap ) { $ this -> collectionsMap = $ this -> repository -> getCollectionsMap ( ) ; } return $ this -> collectionsMap ; }
Returns the collections map storage
46,977
protected function registerEventsTo ( EntityCollection $ collection , $ cid ) { $ collection -> setId ( $ cid ) ; $ collection -> getEmitter ( ) -> addListener ( EntityAdded :: ACTION_ADD , [ $ this , 'updateCollection' ] ) ; $ collection -> getEmitter ( ) -> addListener ( EntityRemoved :: ACTION_REMOVE , [ $ this , 'updateCollection' ] ) ; $ entity = $ this -> repository -> getEntityDescriptor ( ) -> className ( ) ; Orm :: addListener ( $ entity , Delete :: ACTION_AFTER_DELETE , function ( Delete $ event ) use ( $ collection ) { $ collection -> remove ( $ event -> getEntity ( ) ) ; } , EmitterInterface :: P_HIGH ) ; return $ this ; }
Register entity events listeners for the provided collection
46,978
protected function getId ( Select $ query ) { $ str = $ query -> getQueryString ( ) ; $ search = array_keys ( $ query -> getParameters ( ) ) ; $ values = array_values ( $ query -> getParameters ( ) ) ; return str_replace ( $ search , $ values , $ str ) ; }
Gets the id for this query
46,979
protected function updateIdentityMap ( EntityCollection $ collection ) { if ( $ collection -> isEmpty ( ) ) { return $ this ; } foreach ( $ collection as $ entity ) { $ this -> repository -> getIdentityMap ( ) -> set ( $ entity ) ; } return $ this ; }
Registers every entity in collection to the repository identity map
46,980
protected function resourcePathMatch ( File $ file ) { $ source_dirpath = str_replace ( '#' , '\#' , $ this -> sourceDir -> getAbsolutePath ( ) ) ; $ source_dirpath = str_replace ( '[' , '\[' , $ source_dirpath ) ; $ source_dirpath = str_replace ( ']' , '\]' , $ source_dirpath ) ; $ source_dirpath = str_replace ( '(' , '\(' , $ source_dirpath ) ; $ source_dirpath = str_replace ( ')' , '\)' , $ source_dirpath ) ; return preg_match ( '#^' . $ source_dirpath . '/' . $ this -> getRegex ( ) . '#' , $ file -> getAbsolutePath ( ) ) ? TRUE : FALSE ; }
Check if the resource match this road
46,981
public function releaseResource ( AbstractResourceFile $ resource ) { if ( is_null ( $ this -> getReleaseDir ( ) ) ) { throw new Exception ( "ERROR: RELEASE DIR IS NULL: " . $ resource -> getRealPath ( ) ) ; } if ( ! $ this -> getReleaseDir ( ) -> exists ( ) ) { $ this -> getReleaseDir ( ) -> mkdirs ( ) ; } $ release_file = $ this -> makeReleaseFile ( $ resource ) ; $ release_dir = $ release_file -> getAbsoluteFile ( ) -> getParentFile ( ) ; if ( ! $ release_dir -> exists ( ) ) { if ( ! $ release_dir -> mkdirs ( ) ) { throw new FileWriteErrorException ( "The directory '" . $ release_dir -> getAbsolutePath ( ) . "' create fails." ) ; } } \ file_put_contents ( $ release_file -> getAbsolutePath ( ) , $ resource -> getFileContents ( ) ) ; }
Execute the release action for the resource
46,982
public final function makeReleaseFile ( AbstractResourceFile $ resource ) { if ( ! isset ( $ this -> __release__file__map [ $ resource -> getMemberId ( ) ] ) ) { $ this -> __release__file__map [ $ resource -> getMemberId ( ) ] = new File ( $ this -> makeReleaseRelativePath ( $ resource ) , $ this -> getReleaseDir ( ) -> getAbsolutePath ( ) ) ; } return $ this -> __release__file__map [ $ resource -> getMemberId ( ) ] ; }
Generate the file object to release for the given resource .
46,983
public final function getParentProject ( ) { if ( \ is_null ( $ this -> __parent__project ) ) { $ result = ProjectUtil :: searchRelativeProject ( $ this ) ; if ( \ count ( $ result ) < 1 ) { throw new ProjectMemberNotFoundException ( "SOURCE ROAD NOT FOUND" ) ; } $ this -> __parent__project = $ result [ 0 ] ; } return $ this -> __parent__project ; }
Gets the parent of this annotation .
46,984
public function setCondition ( $ field_name , $ value , $ operation = '=' ) { $ this -> condition [ $ field_name ] = [ 'value' => $ value , 'operation' => $ operation ] ; return $ this ; }
Set field conditions .
46,985
public function asQuestion ( ) { $ instance = $ this -> questionClassInstance ( ) -> setMaxAttempts ( $ this -> maxAttempt ) ; if ( $ this -> hidden ) { $ instance -> setHidden ( true ) ; } if ( $ this -> isRequire ( ) ) { $ this -> setValidation ( function ( $ answer ) { if ( $ answer == '' && $ this -> dataType ( ) !== 'boolean' ) { throw new \ Exception ( 'Field is required.' ) ; } } ) ; } $ instance -> setValidator ( function ( $ answer ) { foreach ( $ this -> validation as $ callback ) { if ( ! is_callable ( $ callback ) ) { continue ; } $ callback ( $ answer ) ; } return $ answer ; } ) ; if ( isset ( $ this -> normalizer ) && is_callable ( $ this -> normalizer ) ) { $ instance -> setNormalizer ( $ this -> normalizer ) ; } return $ instance ; }
Field as question instance .
46,986
protected function questionClassInstance ( ) { $ classname = $ this -> questionClass ( ) ; if ( ! class_exists ( $ classname ) ) { throw new \ Exception ( 'Invalid question class.' ) ; } $ instance = ( new \ ReflectionClass ( $ classname ) ) -> newInstanceArgs ( $ this -> questionClassArgs ( ) ) ; if ( ! $ instance instanceof \ Symfony \ Component \ Console \ Question \ Question ) { throw new \ Exception ( 'Invalid question class instance' ) ; } return $ instance ; }
Question class instance .
46,987
public function singleton ( $ alias , $ callback , $ share = false ) { return $ this -> add ( $ alias , $ callback , $ share ) -> setSingleton ( true ) ; }
this method marks your alias as a singleton so it will be resolve only once and reuse everytime
46,988
public function resolve ( $ alias , array $ args = [ ] ) { if ( isset ( $ this -> aliases [ $ alias ] ) ) { $ alias = $ this -> aliases [ $ alias ] ; } $ singleton = $ this -> getBoundManager ( ) -> singleton ( $ alias ) ; if ( $ singleton && $ this -> hasResolvedBefore ( $ alias ) ) { return $ this -> getAlreadyResolved ( $ alias ) ; } if ( false === $ this -> boundManager -> has ( $ alias ) ) { $ this -> add ( $ alias , $ alias ) ; return $ this -> resolve ( $ alias , $ args ) ; } $ definition = $ this -> boundManager -> findDefinition ( $ alias ) ; if ( ! empty ( $ args ) ) { $ this -> getArgumentManager ( ) -> setClassArgs ( $ alias , $ args ) ; } $ resolved = $ this -> checkExpectation ( $ alias , $ this -> resolveObject ( $ definition , $ alias ) ) ; $ this -> saveResolved ( $ alias , $ resolved ) ; if ( $ singleton === true ) { $ this -> removeResolvedFromBound ( $ alias ) ; } return $ resolved ; }
resolves the given alias
46,989
private function resolveObject ( $ definition , $ alias ) { if ( $ definition instanceof \ Closure ) { return $ this -> resolveClosure ( $ alias , $ definition ) ; } try { $ class = new \ ReflectionClass ( $ definition ) ; } catch ( \ ReflectionException $ exception ) { throw new ReflectionException ( $ exception -> getMessage ( ) ) ; } $ this -> resolveProviderAnnotations ( $ class ) ; if ( false === $ class -> isInstantiable ( ) ) { throw new ReflectionException ( sprintf ( '%s class in not instantiable, probably an interface or abstract' , $ class -> getName ( ) ) ) ; } $ constructor = $ class -> getConstructor ( ) ; $ parameters = [ ] ; if ( null !== $ constructor ) { $ this -> resolveInjectAnnotations ( $ constructor , $ alias ) ; $ parameters = $ this -> resolveParameters ( $ constructor , $ this -> argumentManager -> getClassArgs ( $ alias ) ) ; } return $ class -> newInstanceArgs ( $ parameters ) ; }
resolves the instance
46,990
public static function each ( array $ arr , \ Closure $ action ) { foreach ( $ arr as $ k => $ v ) { $ action ( $ v , $ k ) ; } }
Performs an action for each element in the array
46,991
public static function filter ( array $ arr , \ Closure $ predicate ) { $ ret = array ( ) ; foreach ( $ arr as $ k => $ v ) { if ( $ predicate ( $ v , $ k ) ) { $ ret [ $ k ] = $ v ; } } return $ ret ; }
Traverses an array and generates a new array with the returned values
46,992
public static function findKey ( array $ arr , \ Closure $ predicate ) { foreach ( $ arr as $ k => $ v ) { if ( $ predicate ( $ v , $ k ) ) { return $ k ; } } return null ; }
Returns the key for the element which passes the given predicate function
46,993
public static function keysExist ( array $ arr ) { for ( $ i = 1 , $ l = \ func_num_args ( ) - 1 ; $ i <= $ l ; ++ $ i ) { if ( ! \ array_key_exists ( \ func_get_arg ( $ i ) , $ arr ) ) { return false ; } } return true ; }
Checks whether a given set of keys exist in an array
46,994
public static function map ( array $ arr , \ Closure $ callback ) { $ ret = array ( ) ; foreach ( $ arr as $ k => $ v ) { $ ret [ $ k ] = $ callback ( $ v , $ k ) ; } return $ ret ; }
Traverses an array and generates a new array with the returned values which a returned from the callback function
46,995
public static function single ( array $ arr , \ Closure $ predicate ) { foreach ( $ arr as $ k => $ v ) { if ( $ predicate ( $ v , $ k ) ) { return $ v ; } } return null ; }
Returns the value of the first matching predicate
46,996
public static function some ( array $ arr , \ Closure $ predicate ) { foreach ( $ arr as $ k => $ v ) { if ( $ predicate ( $ v , $ k ) ) { return true ; } } return false ; }
Checks if any element passes a predicate function
46,997
public function getPackageInfo ( $ packageName ) { $ composerLock = json_decode ( $ this -> finder -> get ( 'composer.lock' ) ) ; foreach ( $ composerLock -> packages as $ package ) { if ( $ package -> name == $ packageName ) { return $ package ; } } }
Get the exact installed version for the specified package .
46,998
public function getAddressInfo ( ) { $ address = new Address ( ) ; $ address -> setAddress ( $ this -> getAddress ( ) ) ; $ address -> setPostalCode ( $ this -> getPostalCode ( ) ) ; $ address -> setCity ( $ this -> getCity ( ) ) ; if ( ! is_null ( $ this -> getState ( ) ) ) $ address -> setState ( $ this -> getState ( ) ) ; $ address -> setCountry ( $ this -> getCountry ( ) ) ; return $ address ; }
Get address information
46,999
public function send ( RequestInterface $ request ) { $ event = new RequestEvent ( $ request ) ; $ event = $ this -> eventDispatcher -> dispatch ( ClientEvents :: REQUEST , $ event ) ; $ request = $ event -> getRequest ( ) ; $ response = $ this -> httpClient -> send ( $ request ) ; $ event = new ResponseEvent ( $ response ) ; $ event = $ this -> eventDispatcher -> dispatch ( ClientEvents :: RESPONSE , $ event ) ; return $ event -> getResponse ( ) ; }
Sends a psr - 7 request while dispatching request + response events