public function testRemove() { $this->items['alpha'] = new MockComparableItem('alpha'); $this->items['bravo'] = new MockComparableItem('bravo'); $this->items['charlie'] = new MockComparableItem('charlie'); $this->items['delta'] = new MockComparableItem('delta'); $this->object->add($this->items['delta']); $this->object->add($this->items['alpha']); $this->object->add($this->items['bravo']); $this->object->add($this->items['charlie']); $this->object->remove($this->items['bravo']); $expected = array($this->items['alpha'], $this->items['charlie'], $this->items['delta']); $this->assertEquals($expected, $this->readAttribute($this->object, 'elements')); }
/** * Removes any ignored associations, as defined in the model settings, from * the $this->contain array. * * @access public * * @param object $Model Model object * * @return boolean */ private function __removeIgnored($Model) { if (!$this->settings[$Model->alias]['ignore']) { return true; } $ignore = array_unique($this->settings[$Model->alias]['ignore']); foreach ($ignore as $path) { if (Set::check($this->contain, $path)) { $this->contain = Set::remove($this->contain, $path); } } return true; }
/** * Used to delete a variable from Configure. * * Usage: * {{{ * Configure::delete('Name'); will delete the entire Configure::Name * Configure::delete('Name.key'); will delete only the Configure::Name[key] * }}} * * @link http://book.cakephp.org/view/928/delete * @param string $var the var to be deleted * @return void */ public static function delete($var = null) { if (strpos($var, '.') === false) { unset(self::$_values[$var]); return; } $names = explode('.', $var, 2); self::$_values[$names[0]] = Set::remove(self::$_values[$names[0]], $names[1]); }
} catch (Exception $e) { echo get_class($e), ': ', $e->getMessage(), "\n\n"; } // readonly collection echo "Construct as readonly\n"; $set2 = new Set($arr); $set2->freeze(); Debug::dump($set2->isFrozen()); try { echo "Adding Jack\n"; Debug::dump($set2->append($jack)); } catch (Exception $e) { echo get_class($e), ': ', $e->getMessage(), "\n\n"; } try { echo "Removing Jack\n"; $set2->remove($jack); } catch (Exception $e) { echo get_class($e), ': ', $e->getMessage(), "\n\n"; } try { echo "Clearing\n"; $set2->clear(); } catch (Exception $e) { echo get_class($e), ': ', $e->getMessage(), "\n\n"; } foreach ($set2 as $key => &$val) { $val = FALSE; } echo "Contains Jack?\n"; Debug::dump($set2->contains($jack));
/** * Removes a variable from session. * * @param string $name Session variable to remove * @return boolean Success * @access public */ public function delete($name) { if ($this->check($name)) { if (in_array($name, $this->watchKeys)) { trigger_error(sprintf(__('Deleting session key {%s}', true), $name), E_USER_NOTICE); } $this->__overwrite($_SESSION, Set::remove($_SESSION, $name)); return $this->check($name) == false; } $this->__setError(2, sprintf(__("%s doesn't exist", true), $name)); return false; }
/** * Delete a cookie value * * Optional [Name.], required key * $this->Cookie->read('Name.key); * * You must use this method before any output is sent to the browser. * Failure to do so will result in header already sent errors. * * @param string $key * Key of the value to be deleted * @return void * @access public */ function delete($key) { if (empty($this->__values)) { $this->read(); } if (strpos($key, '.') === false) { if (isset($this->__values[$key]) && is_array($this->__values[$key])) { foreach ($this->__values[$key] as $idx => $val) { $this->__delete("[{$key}][{$idx}]"); } } $this->__delete("[{$key}]"); unset($this->__values[$key]); return; } $names = explode('.', $key, 2); if (isset($this->__values[$names[0]])) { $this->__values[$names[0]] = Set::remove($this->__values[$names[0]], $names[1]); } $this->__delete('[' . implode('][', $names) . ']'); }
/** * Delete a cookie value * * Optional [Name.], reguired key * $this->Cookie->read('Name.key); * * You must use this method before any output is sent to the browser. * Failure to do so will result in header already sent errors. * * @param string $key Key of the value to be deleted * @return void * @access public */ public function delete($key) { if (empty($this->__values)) { $this->read(); } if (strpos($key, '.') === false) { unset($this->__values[$key]); $this->__delete("[{$key}]"); return; } $names = explode('.', $key, 2); $this->__values[$names[0]] = Set::remove($this->__values[$names[0]], $names[1]); $this->__delete('[' . implode('][', $names) . ']'); }
/** * Removes a variable from session. * * @param string $name Session variable to remove * @return boolean Success * @access public */ function del($name) { if ($this->check($name)) { if ($var = $this->__validateKeys($name)) { if (in_array($var, $this->watchKeys)) { trigger_error('Deleting session key {' . $var . '}', E_USER_NOTICE); } $this->__overwrite($_SESSION, Set::remove($_SESSION, $var)); return $this->check($var) == false; } } $this->__setError(2, "{$name} doesn't exist"); return false; }
function prepDataForMigration($exclude = array()) { // $this->LocalModel, $this->entry, $this->targetInstance // $Model, $entry, $targetInstance, $settings = $this->LocalModel->migrationSettings(); $exclude = array_merge($exclude, array($this->LocalModel->primaryKey), $settings['excludeFields']); $fullName = $this->LocalModel->getFullName(); $alias = $this->LocalModel->alias; $entry = $this->entry; $assoc = $this->LocalModel->getMigratedAssociations(); if (!empty($assoc)) { foreach ($assoc as $name => $opt) { $paths = array(); if (!empty($opt['path'])) { $paths = Migration::extractPath($entry[$alias], $opt['path']); } elseif (!empty($opt['foreignKey']) && array_key_exists($opt['foreignKey'], $entry[$alias])) { $paths = array($opt['foreignKey'] => $entry[$alias][$opt['foreignKey']]); } //debug($paths); if (!empty($paths)) { $AssocModel = Migration::getLocalModel($opt['className']); foreach ($paths as $path => $local_id) { $removed = false; $remote_id = $AssocModel->getRemoteId($local_id, $this->targetInstance); if (is_null($remote_id)) { if (isset($opt['unsetLevel'])) { $entry[$alias] = Set::remove($entry[$alias], implode('.', array_slice(explode('.', $path), 0, $opt['unsetLevel']))); $removed = true; } if (!empty($opt['autoTrack'])) { $entry['MigrationTracking'][$opt['className']][$local_id] = 1; } if (!empty($opt['autoSelect'])) { $this->Batch->Process->autoSelect[] = array('model' => $opt['className'], 'local_id' => $local_id); } $entry['MigrationMissing'][] = array('model' => $opt['className'], 'local_id' => $local_id); } if (!$removed) { $entry[$alias] = Set::insert($entry[$alias], $path, $remote_id); } } } } //debug($assoc); } //debug($entry[$alias]); $raw = $this->LocalModel->getRawEntry($entry); $data = $raw[$alias]; $data = array_diff_key($data, array_flip($exclude)); $entry['MigrationData'] = $data; return $entry; }
/** * Output the flash message into the view. Uses the flash.tpl element. * * @access public * @param array $params * @return string|null */ public function flash(array $params = array()) { if ($this->View->hasObject('Session')) { $message = $this->View->Session->get('App.flash'); $this->View->Session->set('App.flash', ''); } else { $message = Set::extract($_SESSION, 'App.flash'); $_SESSION = Set::remove($_SESSION, 'App.flash'); } if (!empty($message)) { $params = array('message' => $message) + $params; return $this->open('flash', $params); } }
/** * Removes the given element from the collection if it is found. * * @param mixed $value * @param bool $strict Use a strict comparison (===) if TRUE */ public function remove($value, $strict = false) { if ($this->guard !== null) { $this->guard->checkMemberGuard(new GuardPermission(__FUNCTION__, 'call')); } $this->set->remove($value, $strict); }
/** * Remove a menu item * * @param string $path dot separated path in the array. * @return void */ public static function remove($path) { self::$_items = Set::remove(self::$_items, $path); }
/** * testFunkyKeyRemoval method * * @access public * @return void */ function testFunkyKeyRemoval() { $set = Set::remove(array('Session Test' => 'test'), 'Session Test'); $this->assertFalse(Set::check($set, 'Session Test')); }
function __filterMigrationTable($myTables) { $mySchemaInfoKey = array_search($this->_migrationTable, $myTables); $filteredArray = Set::remove($myTables, $mySchemaInfoKey); sort($filteredArray); return $filteredArray; }
/** * Used to delete a variable from the Configure instance. * * Usage: * {{{ * Configure::delete('Name'); will delete the entire Configure::Name * Configure::delete('Name.key'); will delete only the Configure::Name[key] * }}} * * @link http://book.cakephp.org/view/928/delete * @param string $var the var to be deleted * @return void * @access public */ function delete($var = null) { $_this =& Configure::getInstance(); if (strpos($var, '.') === false) { unset($_this->{$var}); return; } $names = explode('.', $var, 2); $_this->{$names[0]} = Set::remove($_this->{$names[0]}, $names[1]); }
function testWritingWithFunkyKeys() { $set = new Set(); $set->insert('Session Test', "test"); $this->assertEqual($set->extract('Session Test'), 'test'); $set->remove('Session Test'); $this->assertFalse($set->check('Session Test')); $this->assertTrue($set->insert('Session Test.Test Case', "test")); $this->assertTrue($set->check('Session Test.Test Case')); }
function _parseOptAliases($opt, $aliases) { foreach ($aliases as $a => $path) { if (Set::check($opt, $a)) { Set::insert($opt, $path, Set::extract($a, $opt)); Set::remove($opt, $a); } } return $opt; }
public function testRemove() { $set = new Set(array(1, 2, 3)); $set->remove(2); self::assertFalse($set->member(2)); }
/** * Removes a variable from session. * * @param string $name Session variable to remove * @return boolean Success */ public static function delete($name) { if (self::check($name)) { self::__overwrite($_SESSION, Set::remove($_SESSION, $name)); return self::check($name) == false; } self::__setError(2, __d('cake_dev', "%s doesn't exist", $name)); return false; }
function get_more_params($excepts = array()) { $datas = $_GET; $excepts = am($this->excepts, array('page')); //On va parcourir les exemptions foreach ($excepts as $except) { if (Set::check($_GET, $except)) { $datas = Set::remove($datas, $except); $exceptPath = explode('.', $except); if (count(Set::classicExtract($datas, $exceptPath[0])) == 0) { $datas = Set::remove($datas, $exceptPath[0]); } } } $moreParams = ''; if (count($datas) > 0) { $moreParams = $this->_recursive_params($datas); } return $moreParams; }
private function _updateFromJsonItem($user, $attempts, $timestamp) { foreach ($attempts as $attempt) { $attempt = Set::remove($attempt, "attempt.challenge.place"); return $this->Challenge->Attempt->insertFromApi($user, $attempt['attempt']['challenge'], $attempt['attempt'], $timestamp); } }
function _filterMigrationTable($myTables) { $filteredArray = Set::remove($myTables, array_search($this->schema_table, $myTables)); sort($filteredArray); return $filteredArray; }
/** * testWritingWithFunkyKeys method * * @access public * @return void */ function testWritingWithFunkyKeys() { $set = Set::insert(array(), 'Session Test', "test"); $this->assertEqual(Set::extract($set, 'Session Test'), 'test'); $set = Set::remove($set, 'Session Test'); $this->assertFalse(Set::check($set, 'Session Test')); $this->assertTrue($set = Set::insert(array(), 'Session Test.Test Case', "test")); $this->assertTrue(Set::check($set, 'Session Test.Test Case')); }
protected function combineFollows($exact) { $top = $this->state->_fsp; $followSet = new Set(array()); for ($i = $top; $i >= 0; $i--) { $localFollowSet = $this->state->following[$i]; /* System.out.println("local follow depth "+i+"="+ localFollowSet.toString(getTokenNames())+")"); */ $followSet->unionInPlace($localFollowSet); if ($exact) { // can we see end of rule? if ($localFollowSet->member(TokenConst::$EOR_TOKEN_TYPE)) { // Only leave EOR in set if at top (start rule); this lets // us know if have to include follow(start rule); i.e., EOF if ($i > 0) { $followSet->remove(TokenConst::$EOR_TOKEN_TYPE); } } else { // can't see end of rule, quit break; } } } return $followSet; }
/** * testWritingWithFunkyKeys method * * @return void */ public function testWritingWithFunkyKeys() { $set = Set::insert(array(), 'Session Test', "test"); $this->assertEquals('test', Set::extract($set, 'Session Test')); $set = Set::remove($set, 'Session Test'); $this->assertFalse(Set::check($set, 'Session Test')); $expected = array('Session Test' => array('Test Case' => 'test')); $this->assertEquals($expected, Set::insert(array(), 'Session Test.Test Case', "test")); $this->assertTrue(Set::check($expected, 'Session Test.Test Case')); }
/** * Permet de supprimer une donnée dans la session * * @param varchar $key Clée de la donnée (Peut être composée de . pour les niveaux) * @return boolean Vrai si la valeur est supprimée, faux sinon * @access static * @author koéZionCMS * @version 0.1 - 30/12/2011 * @see /Koezion/lib/set.php */ static function delete($key) { $_SESSION = Set::remove($_SESSION, $key); return Session::check($key) == false; }