本文整理汇总了PHP中array_udiff函数的典型用法代码示例。如果您正苦于以下问题:PHP array_udiff函数的具体用法?PHP array_udiff怎么用?PHP array_udiff使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_udiff函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switchAction
/**
* Switch Context.
*
* @Route("/switch/{context}/{values}", name="bigfoot_context_switch")
*/
public function switchAction($context, $values)
{
$values = explode(',', $values);
$chosenContexts = array($context => $values);
$user = $this->getUser();
$requestStack = $this->getRequestStack();
if ($this->getContextManager()->isEntityContextualizable(get_class($user), $context)) {
$context = $this->getEntityManager()->getRepository('BigfootContextBundle:Context')->findOneByEntityIdEntityClass($user->getId(), get_class($user));
if ($context) {
$allowedContexts = $context->getContextValues();
$contextsIntersect = array_udiff($chosenContexts, $allowedContexts, array($this, 'intersectContexts'));
$sessionChosenContexts = $this->getSession()->get('bigfoot/context/chosen_contexts');
if ($sessionChosenContexts) {
$contextsDiff = array_udiff($contextsIntersect, $sessionChosenContexts, array($this, 'diffContexts'));
}
if (isset($contextsDiff) && !$contextsDiff) {
$this->getSession()->set('bigfoot/context/chosen_contexts', null);
} else {
$this->getSession()->set('bigfoot/context/chosen_contexts', $contextsIntersect);
}
} else {
$this->getSession()->set('bigfoot/context/chosen_contexts', $chosenContexts);
}
} else {
$this->getSession()->set('bigfoot/context/chosen_contexts', $chosenContexts);
}
return $this->redirect($requestStack->headers->get('referer'));
}
示例2: execute
public function execute(array $collection)
{
$comparer = $this->getComparer();
return array_values(array_udiff($collection, $this->collectionToExcept, function ($a, $b) use($comparer) {
return $comparer->equals($a, $b);
}));
}
示例3: removeUnit
function removeUnit(Unit $unit)
{
// удаление объекта типа Unit
$this->units = array_udiff($this->units, [$unit], function ($a, $b) {
return $a === $b ? 0 : 1;
});
}
示例4: PersistRelationshipChanges
protected function PersistRelationshipChanges(Object\Domain $Domain, Object\UnitOfWork $UnitOfWork, $ParentEntity, $CurrentValue, $HasOriginalValue, $OriginalValue)
{
$RelationshipChanges = [];
$OriginalEntities = [];
$CurrentEntities = [];
if ($HasOriginalValue) {
$OriginalEntities =& $OriginalValue;
}
if (is_array($CurrentValue)) {
$CurrentEntities =& $CurrentValue;
} else {
throw new Object\ObjectException('Invalid value for property on entity %s, array expected, %s given', $this->GetEntityType(), \Storm\Core\Utilities::GetTypeOrClass($CurrentValue));
}
if ($CurrentEntities === $OriginalEntities) {
return $RelationshipChanges;
}
$NewEntities = array_udiff($CurrentEntities, $OriginalEntities, [$this, 'ObjectComparison']);
$RemovedEntities = array_udiff($OriginalEntities, $CurrentEntities, [$this, 'ObjectComparison']);
foreach ($NewEntities as $NewEntity) {
$RelationshipChanges[] = new Object\RelationshipChange($this->RelationshipType->GetPersistedRelationship($Domain, $UnitOfWork, $ParentEntity, $NewEntity), null);
}
foreach ($RemovedEntities as $RemovedEntity) {
$RelationshipChanges[] = new Object\RelationshipChange(null, $this->RelationshipType->GetDiscardedRelationship($Domain, $UnitOfWork, $ParentEntity, $RemovedEntity));
}
return $RelationshipChanges;
}
示例5: compareCallbacks
/**
* Returns true if the callbacks $a and $b are the same.
*
* @param callback $a
* @param callback $b
* @return bool
*/
public static function compareCallbacks($a, $b)
{
if (is_string($a) || is_string($b)) {
return $a === $b;
}
return count(array_udiff($a, $b, array('ezcSignalCallbackComparer', 'comp_func'))) == 0;
}
示例6: testUpdateTimeOnly
/**
* Tests that updating the start time of an event keeps the occurrence IDs.
* This *may* change as occurrences may be able to share the same date
* @see https://github.com/stephenharris/Event-Organiser/issues/240
*
* @see https://wordpress.org/support/topic/all-events-showing-1200-am-as-start-and-end-time
* @see https://github.com/stephenharris/Event-Organiser/issues/195
*/
public function testUpdateTimeOnly()
{
$tz = eo_get_blog_timezone();
$event = array('start' => new DateTime('2013-10-19 15:30:00', $tz), 'end' => new DateTime('2013-10-19 15:45:00', $tz), 'frequeny' => 1, 'schedule' => 'weekly', 'number_occurrences' => 4);
//Create event and store occurrences
$event_id = eo_insert_event($event);
$original_occurrences = eo_get_the_occurrences($event_id);
//Update event
$new_event_data = $event;
$new_event_data['start'] = new DateTime('2013-10-19 14:30:00', $tz);
eo_update_event($event_id, $new_event_data);
//Get new occurrences
$new_occurrences = eo_get_the_occurrences($event_id);
//Compare
$added = array_udiff($new_occurrences, $original_occurrences, '_eventorganiser_compare_dates');
$removed = array_udiff($original_occurrences, $new_occurrences, '_eventorganiser_compare_dates');
$updated = array_intersect_key($new_occurrences, $original_occurrences);
$updated_2 = array_intersect_key($original_occurrences, $new_occurrences);
$updated = $this->array_map_assoc('eo_format_datetime', $updated, array_fill(0, count($updated), 'Y-m-d H:i:s'));
$updated_2 = $this->array_map_assoc('eo_format_datetime', $updated_2, array_fill(0, count($updated_2), 'Y-m-d H:i:s'));
//Check added/removed/update dates are as expected: all dates should just be updated
$this->assertEquals(array(), $added);
$this->assertEquals(array(), $removed);
$this->assertEquals(array('2013-10-19 14:30:00', '2013-10-26 14:30:00', '2013-11-02 14:30:00', '2013-11-09 14:30:00'), array_values($updated));
//Now check that dates have been updated as expected (i.e. there have been no 'swapping' of IDs).
//First: Sanity check, make sure IDs agree.
$diff = array_diff_key($updated, $updated_2);
$this->assertTrue(empty($diff) && count($updated) == count($updated_2));
ksort($updated);
ksort($updated_2);
$updated_map = array_combine($updated_2, $updated);
//Now check that the dates have been updated as expected: original => new
$this->assertEquals(array('2013-10-19 15:30:00' => '2013-10-19 14:30:00', '2013-10-26 15:30:00' => '2013-10-26 14:30:00', '2013-11-02 15:30:00' => '2013-11-02 14:30:00', '2013-11-09 15:30:00' => '2013-11-09 14:30:00'), $updated_map);
}
示例7: removeUnit
/**
* @param Unit $unit
* @return $this|void
*/
public function removeUnit(Unit $unit)
{
$this->units = array_udiff($this->units, [$unit], function ($a, $b) {
return $a === $b ? 0 : 1;
});
return $this;
}
示例8: bookingAction
/**
*@Security("has_role('ROLE_USER')")
*@Route("/programme/booking/{projection_id}", name ="booking")
*/
public function bookingAction(Request $request, $projection_id)
{
$em = $this->getDoctrine()->getManager();
//retrieve a projection from the database
$projection = $em->getRepository('AppBundle:Projection')->find($projection_id);
//all seats available for the projection
$allSeats = $projection->getHall()->getSeats()->toArray();
//get reserved tickets for the projection
$reservedTickets = $em->createQueryBuilder()->select('t')->from('AppBundle:Ticket', 't')->where('t.projection = ?1')->setParameter(1, $projection)->getQuery()->getResult();
//get reserved seats for the projection
$reservedSeats = array();
foreach ($reservedTickets as $ticket) {
$reservedSeats[] = $ticket->getSeat();
}
// get free seats
$freeSeats = array_udiff($allSeats, $reservedSeats, function ($hallSeat, $reservedSeat) {
return $hallSeat->getId() - $reservedSeat->getId();
});
//a ticket which will be stored
$ticket = new Ticket();
$form = $this->createForm(new BookProjectionForm($freeSeats), $ticket);
$form->handleRequest($request);
if ($form->isValid()) {
//set the other fields
$ticket->setUser($this->getUser())->setProjection($projection)->setTicketPrice($ticket->getPriceCategory()->getCategoryPrice())->setBookingDate(new \DateTime('now'));
$em->persist($ticket);
$em->flush();
// redirect to reservations page
return $this->redirectToRoute('reservations');
}
return $this->render('User/booking.html.twig', array('projection' => $projection, 'form' => $form->createView()));
}
示例9: parse
/**
* Parses the search text to a query wich will search in each of the specified fields.
* If operators AND, OR or NOT are used in the text it is considered search text query and is passed as it is.
* If it is a simple text - it is escaped and truncated.
*
* @param string $searchText
* @param array $fields
* @param string $truncate
*/
public function parse($searchText, $truncate, $fields)
{
$nonTokenizedFields = array_uintersect($fields, self::$_nonTokenizedFields, array('OpenSKOS_Solr_Queryparser_Editor_ParseSearchText', 'compareMultiLangFields'));
$fields = array_udiff($fields, self::$_nonTokenizedFields, array('OpenSKOS_Solr_Queryparser_Editor_ParseSearchText', 'compareMultiLangFields'));
$simpleFieldsQuery = '';
$normalFieldsQuery = '';
if ($this->_isSearchTextQuery($searchText)) {
$simpleFieldsQuery = $this->_buildQueryForSearchTextInFields('(' . $searchText . ')', $nonTokenizedFields);
$normalFieldsQuery = $this->_buildQueryForSearchTextInFields('(' . $searchText . ')', $fields);
} else {
$trimedSearchText = trim($searchText);
if (empty($trimedSearchText)) {
$searchText = '*';
}
$searchTextForNonTokenized = $this->_escapeSpecialChars($searchText);
$simpleFieldsQuery = $this->_buildQueryForSearchTextInFields('(' . $searchTextForNonTokenized . ')', $nonTokenizedFields);
$searchTextForTokenized = $this->_replaceTokenizeDelimiterChars($searchText);
$normalFieldsQuery = $this->_buildQueryForSearchTextInFields('(' . $searchTextForTokenized . ')', $fields);
}
if ($simpleFieldsQuery != '' && $normalFieldsQuery != '') {
return $simpleFieldsQuery . ' OR ' . $normalFieldsQuery;
} else {
return $simpleFieldsQuery . $normalFieldsQuery;
}
}
示例10: index
/**
*
*/
public function index()
{
if ($this->session->userdata('logged_in')) {
$thisUserID = $this->session->userdata('logged_in')['userID'];
$courses = $this->Model_course->GetAllCourses();
$userCourses = $this->Model_usercourse->GetUserCourses($thisUserID);
if ($courses) {
$coursesAvail = array_udiff($courses, $userCourses, function ($courses, $userCourses) {
return $courses->courseID - $userCourses->courseID;
});
$data['courses'] = $courses;
$data['coursesAvail'] = $coursesAvail;
$data['count_coursesAvail'] = count($coursesAvail);
}
//List of courses the user is enrolled in
if ($userCourses) {
$data['userCourses'] = $userCourses;
}
//Count of courses the user is enrolled in
$count = $this->Model_usercourse->GetNumberOfUserCourses();
if ($count) {
$data['NoOfUserCourses'] = $count;
}
//Count of the total nunmber of courses
$count = $this->Model_course->GetNumberOfCourses();
if ($count) {
$data['NoOfCourses'] = $count;
}
//Count of the number of groups in the system
$count = $this->Model_group->GetNumberofGroups();
if ($count) {
$data['NoOfGroups'] = $count;
}
//List of groups in the system
$groups = $this->Model_group->GetGroups();
if ($groups) {
$data['userGroups'] = $groups;
}
$session_data = $this->session->userdata('logged_in');
$data['userID'] = $session_data['userID'];
$data['fname'] = $session_data['fname'];
$data['lname'] = $session_data['lname'];
$data['usertype'] = $session_data['usertype'];
$data['email'] = $session_data['email'];
$data['menu'] = "home";
//List of courses completed by a user, null if there is none
$query = $this->Model_usercourse->GetCompletedUserCourse($data['userID']);
if ($query) {
$data['completedUserCourses'] = $query;
} else {
$data['completedUserCourses'] = null;
}
$this->load->view('header', $data);
$this->load->view('view_dashboard');
} else {
//If no session, redirect to login page
redirect('login', 'refresh');
}
}
示例11: removeUnit
function removeUnit(Unit $unit)
{
// >= php 5.3
//$this->units = array_udiff( $this->units, array( $unit ),
// function( $a, $b ) { return ($a === $b)?0:1; } );
// < php 5.3
$this->units = array_udiff($this->units, array($unit), create_function('$a,$b', 'return ($a === $b)?0:1;'));
}
示例12: execute
public function execute(array $collection)
{
$comparer = $this->getComparer();
$diffed = array_udiff($this->additionalCollection, $collection, function ($a, $b) use($comparer) {
return $comparer->equals($a, $b);
});
return array_merge($collection, $diffed);
}
示例13: detach
function detach(Observer $observer)
{
// >= php 5.3
//$this->observers = array_udiff( $this->observers, array( $observer ),
// function( $a, $b ) { return ($a === $b)?0:1; } );
// < php 5.3
$this->observers = array_udiff($this->observers, array($observer), create_function('$a,$b', 'return ($a === $b)?0:1;'));
}
示例14: removePermission
/**
* {@inheritdoc}
*/
public function removePermission(PermissionInterface $permission)
{
if ($this->hasPermission($permission)) {
$this->permissions = array_udiff($this->permissions, [$permission], function ($objectA, $objectB) {
return $objectA->getHash() - $objectB->getHash();
});
}
return $this;
}
示例15: diff
public static function diff(array $a, array $b)
{
return array_udiff($a, $b, function ($a, $b) {
if (gettype($a) !== gettype($b)) {
return -1;
}
return $a === $b ? 0 : 1;
});
}