idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
235,100 | protected function expectNumberNotZeroForDivision ( $ number , $ message = '' ) { $ this -> expectValidNumber ( $ number , $ message ) ; if ( $ number == 0 ) { throw new DivideByZeroException ( $ message ) ; } } | Expects a number not to be zero when using for division . |
235,101 | public function addHash ( $ options ) { if ( is_string ( $ options ) ) { $ options = array ( $ options ) ; } else if ( ! is_array ( $ options ) ) { throw new Zend_Validate_Exception ( "False parameter given" ) ; } $ known = hash_algos ( ) ; if ( ! isset ( $ options [ 'algorithm' ] ) ) { $ algorithm = 'crc32' ; } else {... | Adds the hash for one or multiple files |
235,102 | public function index ( ) { $ this -> authorize ( DashboardPolicy :: PERMISSION_STATS ) ; $ this -> setTitle ( trans ( 'blog::dashboard.titles.statistics' ) ) ; return $ this -> view ( 'admin.dashboard' ) ; } | Get the dashboard page . |
235,103 | public function flash ( $ message = null , $ type = null ) { if ( $ message !== null ) $ this -> attributes [ 'message' ] = ( array ) $ message ; if ( $ type !== null ) $ this -> attributes [ 'type' ] = $ type ; $ this -> session -> flash ( 'notifier' , $ this -> attributes ) ; } | Save the setup to a session flash . |
235,104 | protected function runQuery ( $ raw_query , $ id ) { $ query = str_replace ( ':id' , $ id , $ raw_query ) ; $ start = microtime ( true ) ; $ results = DB :: getReadPdo ( ) -> query ( $ query ) -> fetchAll ( \ PDO :: FETCH_OBJ ) ; DB :: logQuery ( $ raw_query , [ $ id ] , round ( ( microtime ( true ) - $ start ) * 1000 ... | Execute the query with the current PDO connection . Will log the time taken manually |
235,105 | protected function assembleQuery ( $ initial , $ recursive ) { $ tmp_tbl = 'name_tree' ; $ recursive = str_replace ( ':tmp_tbl' , $ tmp_tbl , $ recursive ) ; $ final = "select distinct * from $tmp_tbl" ; if ( DB :: connection ( ) -> getDriverName ( ) == 'mysql' ) { return "Call WITH_EMULATOR('$tmp_tbl', '$initial', '$r... | Prepare the complete query to run on the DB to get the data recursively . |
235,106 | public function getConfig ( ) { $ config = false ; if ( file_exists ( realpath ( __DIR__ . "/../ExactTargetLaravelConfig.php" ) ) ) { $ config = include __DIR__ . "/../ExactTargetLaravelConfig.php" ; return $ config ; } return $ config ; } | Gets the Configuration |
235,107 | public function refreshToken ( $ forceRefresh = false ) { if ( property_exists ( $ this , "sdl" ) && $ this -> sdl == 0 ) { parent :: __construct ( $ this -> xmlLoc , array ( 'trace' => 1 , 'exceptions' => 0 ) ) ; } try { $ currentTime = new DateTime ( ) ; if ( is_null ( $ this -> getAuthTokenExpiration ( $ this -> ten... | Gets the refresh token using the authentication URL . |
235,108 | public function setAuthToken ( $ tenantKey , $ authToken , $ authTokenExpiration ) { if ( $ this -> tenantTokens [ $ tenantKey ] == null ) { $ this -> tenantTokens [ $ tenantKey ] = array ( ) ; } $ this -> tenantTokens [ $ tenantKey ] [ 'authToken' ] = $ authToken ; $ this -> tenantTokens [ $ tenantKey ] [ 'authTokenEx... | Set the authentication token in the tenantTokens array . |
235,109 | public function getAuthTokenExpiration ( $ tenantKey ) { $ tenantKey = $ tenantKey == null ? $ this -> tenantKey : $ tenantKey ; if ( $ this -> tenantTokens [ $ tenantKey ] == null ) { $ this -> tenantTokens [ $ tenantKey ] = array ( ) ; } return isset ( $ this -> tenantTokens [ $ tenantKey ] [ 'authTokenExpiration' ] ... | Get the Auth Token Expiration . |
235,110 | public function setInternalAuthToken ( $ tenantKey , $ internalAuthToken ) { if ( $ this -> tenantTokens [ $ tenantKey ] == null ) { $ this -> tenantTokens [ $ tenantKey ] = array ( ) ; } $ this -> tenantTokens [ $ tenantKey ] [ 'internalAuthToken' ] = $ internalAuthToken ; } | Set the internal auth tokan . |
235,111 | public function setRefreshToken ( $ tenantKey , $ refreshToken ) { if ( $ this -> tenantTokens [ $ tenantKey ] == null ) { $ this -> tenantTokens [ $ tenantKey ] = array ( ) ; } $ this -> tenantTokens [ $ tenantKey ] [ 'refreshToken' ] = $ refreshToken ; } | Set the refresh authentication token . |
235,112 | public function getRefreshToken ( $ tenantKey ) { $ tenantKey = $ tenantKey == null ? $ this -> tenantKey : $ tenantKey ; if ( $ this -> tenantTokens [ $ tenantKey ] == null ) { $ this -> tenantTokens [ $ tenantKey ] = array ( ) ; } return isset ( $ this -> tenantTokens [ $ tenantKey ] [ 'refreshToken' ] ) ? $ this -> ... | Get the refresh token for the tenant . |
235,113 | public function AddSubscriberToList ( $ emailAddress , $ listIDs , $ subscriberKey = null ) { $ newSub = new ET_Subscriber ; $ newSub -> authStub = $ this ; $ lists = array ( ) ; foreach ( $ listIDs as $ key => $ value ) { $ lists [ ] = array ( "ID" => $ value ) ; } $ newSub -> props = array ( "EmailAddress" => $ email... | Add subscriber to list . |
235,114 | public function CreateDataExtensions ( $ dataExtensionDefinitions ) { $ newDEs = new ET_DataExtension ( ) ; $ newDEs -> authStub = $ this ; $ newDEs -> props = $ dataExtensionDefinitions ; $ postResponse = $ newDEs -> post ( ) ; return $ postResponse ; } | Create a new data extension based on the definition passed |
235,115 | public function SendTriggeredSends ( $ arrayOfTriggeredRecords ) { $ sendTS = new ET_TriggeredSend ( ) ; $ sendTS -> authStub = $ this ; $ sendTS -> props = $ arrayOfTriggeredRecords ; $ sendResponse = $ sendTS -> send ( ) ; return $ sendResponse ; } | Starts an send operation for the TriggerredSend records |
235,116 | public function SendEmailToDataExtension ( $ emailID , $ sendableDataExtensionCustomerKey , $ sendClassficationCustomerKey ) { $ email = new ET_Email_SendDefinition ( ) ; $ email -> props = array ( "Name" => uniqid ( ) , "CustomerKey" => uniqid ( ) , "Description" => "Created with FuelSDK" ) ; $ email -> props [ "SendC... | Create an email send definition send the email based on the definition and delete the definition . |
235,117 | public function CreateProfileAttributes ( $ allAttributes ) { $ attrs = new ET_ProfileAttribute ( ) ; $ attrs -> authStub = $ this ; $ attrs -> props = $ allAttributes ; return $ attrs -> post ( ) ; } | Create a profile attribute |
235,118 | public function CreateContentAreas ( $ arrayOfContentAreas ) { $ postC = new ET_ContentArea ( ) ; $ postC -> authStub = $ this ; $ postC -> props = $ arrayOfContentAreas ; $ sendResponse = $ postC -> post ( ) ; return $ sendResponse ; } | Create one or more content areas |
235,119 | public static function Create ( string $ folder , int $ mode = 0700 ) { if ( \ is_dir ( $ folder ) ) { return ; } if ( ! static :: CanCreate ( $ folder ) ) { throw new FolderAccessError ( 'IO' , $ folder , FolderAccessError :: ACCESS_CREATE , 'Creation of folder fails cause base folder is not writable!' ) ; } try { if ... | Creates a new folder with defined mode . The mode only works on unixoid systems . |
235,120 | public static function ListFilteredFiles ( string $ folder , $ filter , bool $ recursive = false ) : array { $ files = array ( ) ; if ( ! \ is_dir ( $ folder ) ) { return $ files ; } if ( ! $ recursive ) { $ d = \ dir ( $ folder ) ; while ( false !== ( $ entry = $ d -> read ( ) ) ) { if ( $ entry == '.' || $ entry == '... | Returns all files matching the defined filter . |
235,121 | final public function slice ( $ offset , $ length = null , $ preserve_keys = false ) { $ arr = array_unshift ( $ this -> { self :: MAGIC_PROPERTY } , $ offset , $ length , $ preserve_keys ) ; return static :: createFromArray ( $ arr ) ; } | Extract a slice of the array |
235,122 | final public function chunk ( $ size , $ preserve_keys = false ) { $ arr = array_chunk ( $ this -> { self :: MAGIC_PROPERTY } , $ size , $ preserve_keys ) ; return static :: createFromArray ( $ arr ) ; } | Split an array into chunks |
235,123 | final public function search ( $ needle , $ strict = false ) { return array_search ( $ needle , $ this -> { self :: MAGIC_PROPERTY } , $ strict ) ; } | Searches the array for a given value and returns the corresponding key if successful |
235,124 | final public function keys ( $ search_value = null , $ strict = false ) { if ( isset ( $ search_value ) ) { return static :: createFromArray ( array_keys ( $ this -> { self :: MAGIC_PROPERTY } , $ search_value , $ strict ) ) ; } else { return static :: createFromArray ( array_keys ( $ this -> { self :: MAGIC_PROPERTY }... | Return all the keys or a subset of the keys of an array |
235,125 | final public function replace ( ) { $ args = func_get_args ( ) ; array_unshift ( $ this -> { self :: MAGIC_PROPERTY } , $ args ) ; $ arr = call_user_func_array ( 'array_replace' , $ args ) ; return static :: createFromArray ( $ arr ) ; } | Replaces elements from passed arrays into the first array |
235,126 | final public function pad ( $ size , $ value ) { return static :: createFromArray ( array_pad ( $ this -> { self :: MAGIC_PROPERTY } , $ size , $ value ) ) ; } | Pad array to the specified length with a value |
235,127 | final public function multisort ( $ array1_sort_order = SORT_ASC , $ array1_sort_flags = SORT_REGULAR ) { return array_multisort ( $ this -> { self :: MAGIC_PROPERTY } , $ array1_sort_order , $ array1_sort_flags ) ; } | Sort multiple or multi - dimensional arrays |
235,128 | final public function unique ( $ sort_flags = SORT_STRING ) { $ arr = array_unique ( $ this -> { self :: MAGIC_PROPERTY } , $ sort_flags ) ; return static :: createFromArray ( $ arr ) ; } | Removes duplicate values from an array |
235,129 | final public function map ( Callable $ callback ) { $ arr = array_map ( $ callback , array_values ( $ this -> { self :: MAGIC_PROPERTY } ) , array_keys ( $ this -> { self :: MAGIC_PROPERTY } ) ) ; return static :: createFromArray ( $ arr ) ; } | Applies the callback to the elements of the array |
235,130 | final public function walk ( Callable $ callback , $ userdata = null ) { array_walk ( $ this -> { self :: MAGIC_PROPERTY } , $ callback ) ; return $ this ; } | Apply a user supplied function to every member of an array |
235,131 | final public function filter ( Callable $ callback , $ flags = 0 ) { $ arr = array_filter ( $ this -> { self :: MAGIC_PROPERTY } , $ callback ) ; return static :: createFromArray ( $ arr ) ; } | Filters elements of an array using a callback function |
235,132 | final public function reduce ( Callable $ callback , $ initial = null ) { $ result = array_reduce ( $ this -> { self :: MAGIC_PROPERTY } , $ callback , $ initial ) ; return static :: from ( $ result ) ; } | Iteratively reduce the array to a single value using a callback function |
235,133 | public function cmdGetPayment ( ) { $ result = $ this -> getListPayment ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTablePayment ( $ result ) ; $ this -> output ( ) ; } | Callback for payment - get command |
235,134 | protected function getErrorCode ( ) { $ content = $ this -> content ; return is_object ( $ content ) && property_exists ( $ content , 'code' ) ? ( integer ) $ content -> code : 0 ; } | returns the response error code |
235,135 | public function flush ( ) { if ( empty ( $ this -> memcache ) ) { return false ; } $ flushStatus = $ this -> memcache -> flush ( ) ; return $ flushStatus ; } | Flush the server |
235,136 | public static function createTemporary ( string $ data , string $ clientFileName = null ) : File { $ tempFilePath = tempnam ( sys_get_temp_dir ( ) , 'dms' ) ; file_put_contents ( $ tempFilePath , $ data ) ; return new self ( $ tempFilePath , $ clientFileName ) ; } | Create a temporary temporary file . |
235,137 | protected function readChunkHeader ( ) { static $ m = NULL ; if ( preg_match ( "'([a-fA-F0-9]+).*\r\n'" , $ this -> buffer , $ m ) ) { $ this -> remainder = hexdec ( $ m [ 1 ] ) ; $ this -> buffer = ( string ) substr ( $ this -> buffer , strlen ( $ m [ 0 ] ) ) ; } else { $ this -> remainder = 0 ; } } | Compute number of remaining bytes using chunk header |
235,138 | protected function BeforeDelete ( ) { foreach ( self :: $ deleteHooks as $ hook ) { $ hook -> BeforeDelete ( $ this -> item ) ; } $ logger = new Logger ( BackendModule :: Guard ( ) -> GetUser ( ) ) ; $ logger -> ReportAreaAction ( $ this -> item , Action :: Delete ( ) ) ; } | Execute delete hooks |
235,139 | public function normalizeData ( PathUserResponse $ response ) { $ return = $ response -> getResponse ( ) ; $ provider = $ response -> getResourceOwner ( ) -> getName ( ) ; $ token = $ response -> getAccessToken ( ) ; switch ( $ provider ) { case 'google' : $ data = $ this -> normalizeGoogle ( $ return ) ; break ; case ... | Get oAuth data and normalize it to same var names |
235,140 | public function normalizeGoogle ( $ return ) { $ genders = [ 'male' => 'M' , 'female' => 'F' ] ; $ data = [ 'id' => $ return [ 'id' ] , 'name' => $ this -> ensureUtf8 ( $ return [ 'name' ] ) , 'firstName' => $ this -> ensureUtf8 ( $ return [ 'given_name' ] ) , 'lastName' => $ this -> ensureUtf8 ( $ return [ 'family_nam... | Mapping data from Google |
235,141 | public function normalizeFacebook ( $ return ) { $ genders = [ 'male' => 'M' , 'female' => 'F' ] ; $ data = [ 'id' => $ return [ 'id' ] , 'name' => $ return [ 'name' ] , 'firstName' => $ return [ 'first_name' ] , 'lastName' => $ return [ 'last_name' ] , 'facebookProfileLink' => $ return [ 'link' ] , 'username' => $ ret... | Mapping data from facbook |
235,142 | public function normalizeGithub ( $ return , $ token ) { $ data = [ 'id' => $ return [ 'id' ] , 'username' => $ return [ 'login' ] , 'name' => $ return [ 'name' ] , 'email' => $ return [ 'email' ] , 'gravatar' => $ return [ 'gravatar_id' ] , 'avatar' => $ return [ 'avatar_url' ] , 'gitHubProfileLink' => $ return [ 'htm... | Mapping data from github |
235,143 | protected function httpRequest ( $ url , $ resource = '/' , $ content = null , $ headers = [ ] , $ method = 'GET' ) { $ request = new HttpRequest ( $ method , $ resource , $ url ) ; $ response = new HttpResponse ( ) ; $ headers = array_merge ( [ 'User-Agent: WobbleCodeUserBundle' ] , $ headers ) ; $ request -> setHeade... | Performs an HTTP request |
235,144 | public function GetReferencedContainer ( Content $ content ) { $ contentContainer = ContentContainer :: Schema ( ) -> ByContent ( $ content ) ; return $ contentContainer ? $ contentContainer -> GetContainer ( ) : null ; } | Gets a container referenced by a content |
235,145 | protected function activationComplete ( ) { try { $ activation = Activation :: create ( $ this -> model ) ; if ( ! Activation :: complete ( $ this -> model , $ activation -> code ) ) { throw new ActivateException ( $ this -> model -> id , $ activation -> code , 'fail' ) ; } if ( $ this -> callerActivationMethod ( debug... | set activation complete |
235,146 | protected function activateGroupAction ( $ class ) { $ users = $ class :: whereIn ( 'id' , $ this -> request -> id ) -> get ( ) ; foreach ( $ users as $ user ) { $ this -> setModel ( $ user ) ; $ this -> activationComplete ( ) ; } return true ; } | activate group action |
235,147 | protected function notActivateGroupAction ( $ class ) { $ users = $ class :: whereIn ( 'id' , $ this -> request -> id ) -> get ( ) ; foreach ( $ users as $ user ) { $ this -> setModel ( $ user ) ; $ this -> activationRemove ( ) ; } return true ; } | not activate group action |
235,148 | public static function addDirectory ( $ directory , $ extensionToFind = '.php' , $ bypassDirectories = '' ) { self :: register ( ) ; $ dir = new SplFileInfo ( $ directory ) ; if ( ! $ dir -> isDir ( ) ) { throw new ApplicationContextException ( 'Cannot add directory to ClassLoader, directory does not exist: ' . $ direc... | Scans a directory recursively for all files with a particular extension and will add any classes it finds with the full path . |
235,149 | public static function addFile ( $ filePath , $ extensionToFind = '.php' ) { if ( ! $ filePath instanceof SplFileInfo ) { $ filePath = new SplFileInfo ( $ filePath ) ; } $ firstChar = substr ( $ filePath -> getBasename ( ) , 0 , 1 ) ; $ extension = substr ( $ filePath -> getFilename ( ) , strlen ( $ extensionToFind ) *... | Evaluates a file and if it looks like a php class it will add it . This prevents odd php files that aren t classes from being auto loaded like bootstrap . php or autoload . php etc . |
235,150 | public static function addClass ( $ className , $ filePath ) { if ( self :: classExists ( $ className ) ) { throw new ApplicationContextException ( 'Cannot add class file [' . $ filePath . '], class with same name already defined by [' . self :: $ classNames [ $ className ] . ']' ) ; } self :: $ classNames [ $ classNam... | Adds a class name and file path . |
235,151 | public static function isVcsFile ( $ fileName ) { foreach ( self :: $ vcsPatterns as $ pattern ) { if ( strpos ( $ fileName , $ pattern ) !== false ) { return true ; } } return false ; } | Returns true if file path contains a vcs name . |
235,152 | public function apply ( $ value ) { return htmlspecialchars ( ( string ) $ value , $ this -> quoteStyle , $ this -> charset , $ this -> doubleEncode ) ; } | Converts special characters to HTML entities |
235,153 | private function __connect ( ) { if ( ! is_null ( $ db ) ) return true ; $ config = Config :: get ( 'db' ) ; if ( is_null ( $ config ) ) { throw new \ Lollipop \ Exception \ Configuration ( 'Lollipop is initialized with wrong database configuration' ) ; } $ host = isset ( $ config -> host ) ? $ config -> host : 'localh... | Connect to MySQL server |
235,154 | public function initialize ( $ csrf = false ) { $ this -> _tokenRequired = $ csrf ; if ( $ csrf ) { $ currentToken = App :: $ Session -> get ( '_csrf_token' , false ) ; $ newToken = Crypt :: randomString ( mt_rand ( 32 , 64 ) ) ; App :: $ Session -> set ( '_csrf_token' , $ newToken ) ; if ( $ this -> send ( ) ) { if ( ... | Initialize validator . Set csrf protection token from request data if available . |
235,155 | final public function send ( ) { if ( ! Str :: equalIgnoreCase ( $ this -> _sendMethod , App :: $ Request -> getMethod ( ) ) ) { return false ; } return $ this -> getRequest ( 'submit' , $ this -> _sendMethod ) !== null ; } | Check if model get POST - based request as submit of SEND data |
235,156 | public function getRequest ( $ param , $ method = null ) { if ( $ method === null ) { $ method = $ this -> _sendMethod ; } $ method = Str :: lowerCase ( $ method ) ; switch ( $ method ) { case 'get' : $ request = App :: $ Request -> query -> get ( $ this -> getFormName ( ) , null ) ; break ; case 'post' : $ request = A... | Get input value based on param path and request method |
235,157 | public static function fromRepository ( $ repository ) { $ message = sprintf ( 'Could not add invalid OptionRepository of type "%1$s" to AggregateOptionRepository.' , is_object ( $ repository ) ? get_class ( $ repository ) : gettype ( $ repository ) ) ; return new static ( $ message ) ; } | Get a new exception based on the type of an invalid repository . |
235,158 | public static function fromInstantiationException ( $ class , Exception $ exception ) { $ message = sprintf ( 'Could not instantiate OptionRepository of type "%1$s". Reason: %2$s' , is_object ( $ class ) ? get_class ( $ class ) : gettype ( $ class ) , $ exception -> getMessage ( ) ) ; return new static ( $ message , 0 ... | Get a new exception based on an exception that was thrown during instantiation of a class . |
235,159 | public static function fromConfig ( Config $ config ) { $ message = sprintf ( 'Could not instantiate OptionRepository from Config with starting key "%1$s".' , empty ( $ config -> getKeys ( ) ) ? '<none>' : $ config -> getKeys ( ) [ 0 ] ) ; return new static ( $ message ) ; } | Get a new exception based on a Config that did not produce a valid repository . |
235,160 | protected function setValue ( $ value ) { $ enumKey = array_search ( ( string ) $ value , static :: $ enumConstants [ get_class ( $ this ) ] ) ; if ( $ enumKey === false ) { throw new Exception \ InvalidEnumerationValueException ( sprintf ( 'Invalid value %s for %s' , $ value , __CLASS__ ) , 1381615295 ) ; } $ this -> ... | Set the Enumeration value to the associated enumeration value by a loose comparison . The value that is used as the enumeration value will be of the same type like defined in the enumeration |
235,161 | protected function isValid ( $ value ) { $ value = ( string ) $ value ; foreach ( static :: $ enumConstants [ get_class ( $ this ) ] as $ constantValue ) { if ( $ value === ( string ) $ constantValue ) { return true ; } } return false ; } | Check if the value on this enum is a valid value for the enum |
235,162 | public static function getConstants ( $ include_default = false ) { static :: loadValues ( ) ; $ enumConstants = static :: $ enumConstants [ get_called_class ( ) ] ; if ( ! $ include_default ) { unset ( $ enumConstants [ '__DEFAULT' ] ) ; } return $ enumConstants ; } | Get the valid values for this enum Defaults to constants you define in your subclass override to provide custom functionality |
235,163 | public static function cast ( $ value ) { $ currentClass = get_called_class ( ) ; if ( ! is_object ( $ value ) || get_class ( $ value ) !== $ currentClass ) { $ value = new $ currentClass ( $ value ) ; } return $ value ; } | Cast value to enumeration type |
235,164 | public function readConfig ( $ pipe ) { $ filename = $ this -> pipesDir . '/' . $ pipe ; if ( file_exists ( $ filename . '.yml' ) ) { return Yaml :: parse ( file_get_contents ( $ filename . '.yml' ) ) ; } elseif ( $ this -> allowPhp && file_exists ( $ filename . '.php' ) ) { return include ( $ filename . '.php' ) ; } e... | Reads pipe config from file . |
235,165 | public static function pregMatchArray ( $ patterns , $ subject ) { if ( ! is_array ( $ patterns ) ) { throw new \ Exception ( '$patterns is not an array' ) ; } if ( ! is_string ( $ subject ) ) { throw new \ Exception ( '$subject is not a string' ) ; } foreach ( $ patterns as $ pattern ) { if ( preg_match ( $ pattern , ... | Preg match array |
235,166 | final public function requireBasicLogin ( $ realm = 'Restricted' ) { if ( ! ( array_key_exists ( 'PHP_AUTH_USER' , $ _SERVER ) and array_key_exists ( 'PHP_AUTH_PW' , $ _SERVER ) ) ) { $ this -> _basicAuthFailed ( $ realm ) ; } else { $ this -> loginWith ( [ 'user' => $ _SERVER [ 'PHP_AUTH_USER' ] , 'password' => $ _SER... | Check for Basic Auth credentials and attempt to login if present |
235,167 | protected function loadEntity ( ) { $ params = array_merge ( $ this -> params ( ) -> fromPost ( ) , $ this -> params ( ) -> fromRoute ( ) ) ; if ( empty ( $ params [ 'id' ] ) ) { throw new EntityNotFoundException ( 'Bad Request' ) ; } $ objectManager = $ this -> getServiceLocator ( ) -> get ( 'Doctrine\ORM\EntityManage... | Find entity by id |
235,168 | public function getTranslation ( $ identifier , $ defaultTranslation = null ) : string { if ( $ this -> _useNumericId ) { if ( ! \ is_int ( $ identifier ) ) { throw new \ InvalidArgumentException ( 'Current ' . __CLASS__ . ' instance requires numeric identifier!' ) ; } if ( ! isset ( $ this -> _translations [ $ identif... | Gets the translation with the defined identifier |
235,169 | public function getTranslations ( $ category = null ) : array { $ translations = [ ] ; if ( \ is_null ( $ category ) ) { foreach ( $ this -> _translations as $ identifier => $ transData ) { if ( is_string ( $ transData ) ) { $ translations [ $ identifier ] = $ transData ; continue ; } if ( ! \ is_array ( $ transData ) ... | Gets all translations of an specific category . If not category is defined all translations of all categories are returned . |
235,170 | public static function LoadFromFolder ( string $ folder , Locale $ locale , bool $ useNumericId = false ) { $ languageFolderBase = rtrim ( $ folder , '\\/' ) ; if ( ! empty ( $ languageFolderBase ) ) { $ languageFolderBase .= '/' ; } $ languageFile = $ languageFolderBase . $ locale -> getLID ( ) . '_' . $ locale -> get... | Loads a translation array source from a specific folder that contains one or more locale depending PHP files . |
235,171 | public function add ( $ productId , $ count , $ attributesAndValues = null , $ additionalProducts = [ ] , $ combinationId = null ) { if ( ! empty ( $ attributesAndValues ) ) { $ attributesAndValues = Json :: decode ( $ attributesAndValues ) ; } if ( $ this -> saveSelectedCombination ) { $ combination = Combination :: f... | Adds product to cart . |
235,172 | private function saveProductToDataBase ( $ productId , $ count , $ attributesAndValues = null , $ additionalProducts = null , $ combinationId = null ) { $ order = $ this -> getIncompleteOrderFromDB ( ) ; if ( \ Yii :: $ app -> getModule ( 'shop' ) -> enableCombinations ) { if ( ! empty ( $ attributesAndValues ) ) { $ c... | Saves product to database if the corresponding property is true . |
235,173 | private function getIncompleteOrderFromDB ( ) { $ order = Order :: find ( ) -> where ( [ 'user_id' => \ Yii :: $ app -> user -> id , 'status' => OrderStatus :: STATUS_INCOMPLETE ] ) -> one ( ) ; if ( empty ( $ order ) ) { $ order = new Order ( ) ; $ order -> uid = $ this -> generateUniqueId ( $ this -> uidPrefix , $ th... | Gets or creates incomplete order record from database . |
235,174 | public function saveSelectedCombinationToSession ( $ combination ) { if ( ! empty ( $ combination ) ) { $ items = Yii :: $ app -> session [ self :: SESSION_KEY_SELECTED_COMBINATIONS ] ; $ itemIsExist = false ; if ( ! empty ( $ items ) ) { foreach ( $ items as $ key => $ item ) { if ( $ item [ 'productId' ] == $ combina... | Saves last selected product combinations to session . |
235,175 | public function getSelectedCombinationFromSession ( $ productId ) { $ combination = null ; if ( ! empty ( $ productId ) ) { $ items = Yii :: $ app -> session [ self :: SESSION_KEY_SELECTED_COMBINATIONS ] ; if ( ! empty ( $ items ) ) { $ combinationId = null ; foreach ( $ items as $ item ) { if ( $ item [ 'productId' ] ... | Gets last selected product combinations from session . |
235,176 | public function getOrderItems ( ) { if ( \ Yii :: $ app -> user -> isGuest ) { $ session = \ Yii :: $ app -> session ; $ products = $ session [ self :: SESSION_KEY ] ; } else { $ order = Order :: find ( ) -> where ( [ 'user_id' => \ Yii :: $ app -> user -> id , 'status' => OrderStatus :: STATUS_INCOMPLETE ] ) -> one ( ... | Gets order items . |
235,177 | public function getOrderItemsCount ( ) { if ( \ Yii :: $ app -> user -> isGuest ) { $ session = \ Yii :: $ app -> session ; return count ( $ session [ self :: SESSION_KEY ] ) ; } else { $ order = Order :: find ( ) -> where ( [ 'user_id' => \ Yii :: $ app -> user -> id , 'status' => OrderStatus :: STATUS_INCOMPLETE ] ) ... | Gets order items count . |
235,178 | public function getAllUserOrders ( ) { if ( ! \ Yii :: $ app -> user -> isGuest && $ this -> saveToDataBase === true ) { $ orders = Order :: find ( ) -> where ( [ 'user_id' => \ Yii :: $ app -> user -> id ] ) -> andWhere ( [ '!=' , 'status' , OrderStatus :: STATUS_INCOMPLETE ] ) -> all ( ) ; return $ orders ; } else re... | Gets all user orders from database . |
235,179 | public function removeItem ( int $ productId , int $ combinationId = null ) { if ( ! \ Yii :: $ app -> user -> isGuest ) { $ order = Order :: find ( ) -> where ( [ 'user_id' => \ Yii :: $ app -> user -> id , 'status' => OrderStatus :: STATUS_INCOMPLETE ] ) -> one ( ) ; if ( ! empty ( $ order ) ) { $ orderProduct = Orde... | Removes item from order . |
235,180 | public function getIncompleteOrder ( ) { if ( ! \ Yii :: $ app -> user -> isGuest ) { $ user = User :: findOne ( \ Yii :: $ app -> user -> id ) ; $ order = Order :: find ( ) -> where ( [ 'user_id' => $ user -> id , 'status' => OrderStatus :: STATUS_INCOMPLETE ] ) -> one ( ) ; if ( ! empty ( $ order ) ) { return $ order... | Gets registered user s incomplete order |
235,181 | public function clearCart ( ) { if ( ! \ Yii :: $ app -> user -> isGuest && $ this -> saveToDataBase === true ) { $ order = Order :: find ( ) -> where ( [ 'user_id' => \ Yii :: $ app -> user -> id , 'status' => OrderStatus :: STATUS_INCOMPLETE ] ) -> one ( ) ; if ( ! empty ( $ order ) ) $ order -> delete ( ) ; } else {... | Clears cart . |
235,182 | public function getCost ( ) { $ totalCost = 0 ; if ( Yii :: $ app -> user -> isGuest ) { $ session = Yii :: $ app -> session ; $ products = $ session [ self :: SESSION_KEY ] ; if ( ! empty ( $ products ) ) { foreach ( $ products as $ product ) { if ( ! empty ( $ product [ 'combinationId' ] ) ) { $ combination = Combina... | Gets cost of user s incomplete order without discounts |
235,183 | public function getTotalCost ( ) { $ totalCost = $ this -> getCost ( ) ; $ adjustmentTotal = 0 ; foreach ( $ this -> adjustments as $ adjustment ) { $ adjustmentObject = Yii :: createObject ( $ adjustment ) ; if ( $ adjustmentObject instanceof CartSumAdjustment ) { $ adjustmentTotal += $ adjustmentObject -> countAdjust... | Gets total cost of user s incomplete order from session if user is guest or from DB if user is authenticated |
235,184 | public function isContainsProduct ( $ productId , $ combinationId = null ) { if ( Yii :: $ app -> user -> isGuest ) { if ( ! empty ( Yii :: $ app -> session [ self :: SESSION_KEY ] ) ) { $ sessionProducts = Yii :: $ app -> session [ self :: SESSION_KEY ] ; foreach ( $ sessionProducts as $ item ) { $ condition = ( empty... | Checks if the cart contains the product . |
235,185 | public static function init ( ) { if ( is_null ( self :: $ storage ) ) { self :: $ storage = new NativeSessionStorage ( ) ; } self :: $ storage -> start ( ) ; } | initialize session storage mechanism currently only wraps PHP native session storage |
235,186 | public function decrypt ( $ input ) { $ input = base64_decode ( $ input ) ; $ iv = substr ( $ input , 0 , Cipher :: IV_SIZE ) ; return openssl_decrypt ( substr ( $ input , Cipher :: IV_SIZE ) , "AES-256-CBC" , $ this -> secretKey , 0 , $ iv ) ; } | Decrypts the input text from the cipher key |
235,187 | public function filter ( callable $ callback ) : ArrayObject { $ arrayCopy = $ this -> getArrayCopy ( ) ; $ filteredData = array_filter ( $ arrayCopy , $ callback ) ; return new ArrayObject ( $ filteredData ) ; } | Iterates over each value in the array passing them to the callback function . If the callback function returns true the current value from array is returned into the result ArrayObject . Array keys are preserved . |
235,188 | public function first ( ) { $ this -> throwExceptionIfEmpty ( ) ; $ keys = $ this -> keys ( ) ; $ keyOfTheFirstElement = $ keys -> shift ( ) ; return $ this -> offsetGet ( $ keyOfTheFirstElement ) ; } | Returns the first element ignoring the type of the keys . |
235,189 | public function shift ( ) { $ this -> throwExceptionIfEmpty ( ) ; $ arrayCopy = $ this -> getArrayCopy ( ) ; $ firstElement = array_shift ( $ arrayCopy ) ; $ this -> exchangeArray ( $ arrayCopy ) ; return $ firstElement ; } | Shift an element off the beginning of array |
235,190 | public function last ( ) { $ this -> throwExceptionIfEmpty ( ) ; $ keys = $ this -> keys ( ) ; $ keyOfTheLastElement = $ keys -> pop ( ) ; return $ this -> offsetGet ( $ keyOfTheLastElement ) ; } | Returns the last element ignoring the type of the keys . |
235,191 | public function pop ( ) { $ this -> throwExceptionIfEmpty ( ) ; $ arrayCopy = $ this -> getArrayCopy ( ) ; $ lastElement = array_pop ( $ arrayCopy ) ; $ this -> exchangeArray ( $ arrayCopy ) ; return $ lastElement ; } | Pop the element off the end of array |
235,192 | public function initCategories ( $ overrideExisting = true ) { if ( null !== $ this -> collCategories && ! $ overrideExisting ) { return ; } $ collectionClassName = CategoryTableMap :: getTableMap ( ) -> getCollectionClassName ( ) ; $ this -> collCategories = new $ collectionClassName ; $ this -> collCategories -> setM... | Initializes the collCategories collection . |
235,193 | public function getCategories ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collCategoriesPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collCategories || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collCategories ) { $ this... | Gets an array of ChildCategory objects which contain a foreign key that references this object . |
235,194 | public function countCategories ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collCategoriesPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collCategories || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> co... | Returns the number of related Category objects . |
235,195 | public function addCategory ( ChildCategory $ l ) { if ( $ this -> collCategories === null ) { $ this -> initCategories ( ) ; $ this -> collCategoriesPartial = true ; } if ( ! $ this -> collCategories -> contains ( $ l ) ) { $ this -> doAddCategory ( $ l ) ; if ( $ this -> categoriesScheduledForDeletion and $ this -> c... | Method called to associate a ChildCategory object to this object through the ChildCategory foreign key attribute . |
235,196 | public function initMedias ( $ overrideExisting = true ) { if ( null !== $ this -> collMedias && ! $ overrideExisting ) { return ; } $ collectionClassName = MediaTableMap :: getTableMap ( ) -> getCollectionClassName ( ) ; $ this -> collMedias = new $ collectionClassName ; $ this -> collMedias -> setModel ( '\Attogram\S... | Initializes the collMedias collection . |
235,197 | public function getMedias ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collMediasPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collMedias || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collMedias ) { $ this -> initMedias (... | Gets an array of ChildMedia objects which contain a foreign key that references this object . |
235,198 | public function countMedias ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collMediasPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collMedias || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collMedias ) {... | Returns the number of related Media objects . |
235,199 | public function addMedia ( ChildMedia $ l ) { if ( $ this -> collMedias === null ) { $ this -> initMedias ( ) ; $ this -> collMediasPartial = true ; } if ( ! $ this -> collMedias -> contains ( $ l ) ) { $ this -> doAddMedia ( $ l ) ; if ( $ this -> mediasScheduledForDeletion and $ this -> mediasScheduledForDeletion -> ... | Method called to associate a ChildMedia object to this object through the ChildMedia foreign key attribute . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.