_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q248300 | AbstractView.addClass | validation | public function addClass($class)
{
$classes = $this->getClasses();
if (!in_array($class, $classes)) {
$classes[] = $class;
}
$this->setClasses($classes);
return $this;
} | php | {
"resource": ""
} |
q248301 | AbstractView.removeClass | validation | public function removeClass($class)
{
$classes = $this->getClasses();
if (false !== $index = array_search($class, $classes)) {
unset($classes[$index]);
}
$this->setClasses($classes);
return $this;
} | php | {
"resource": ""
} |
q248302 | AbstractView.setClasses | validation | private function setClasses(array $classes)
{
if (!empty($classes)) {
$this->vars['attr']['class'] = ' ' . trim(implode(' ', $classes));
} else {
unset($this->vars['attr']['class']);
}
} | php | {
"resource": ""
} |
q248303 | CustomerUpdater.updateCustomerBalance | validation | protected function updateCustomerBalance(PaymentInterface $payment, $amount = null)
{
if (null === $customer = $payment->getSale()->getCustomer()) {
// TODO Deals with customer change
return false;
}
$amount = $amount ?: $payment->getAmount();
if ($this->isAc... | php | {
"resource": ""
} |
q248304 | CustomerUpdater.getAcceptedStates | validation | protected function getAcceptedStates(PaymentInterface $payment)
{
$acceptedStates = PaymentStates::getPaidStates();
if ($payment->getMethod()->isOutstanding()) {
$acceptedStates[] = PaymentStates::STATE_EXPIRED;
}
return $acceptedStates;
} | php | {
"resource": ""
} |
q248305 | CustomerUpdater.supports | validation | protected function supports(PaymentInterface $payment)
{
if (null === $method = $payment->getMethod()) {
throw new RuntimeException("Payment method must be set.");
}
if ($method->isCredit() || $method->isOutstanding()) {
return true;
}
return false;
... | php | {
"resource": ""
} |
q248306 | AuthActionsTrait.getAuthActions | validation | public function getAuthActions() {
if (!$this->_AuthActions) {
if (Configure::load('auth_actions') === false) {
trigger_error('AuthActions: Could not load config/auth_actions.php', E_USER_WARNING);
}
$actionConfig = Configure::read('auth_actions');
$publicActionsConfig = Configure::read('public_actio... | php | {
"resource": ""
} |
q248307 | AuthActionsTrait.getUserRights | validation | public function getUserRights() {
if (!$this->_UserRights) {
if (Configure::load('user_rights') === false) {
trigger_error('UserRights: Could not load config/user_rights.php', E_USER_WARNING);
}
$rightsConfig = Configure::read('user_rights');
if (!is_array($rightsConfig)) {
$rightsConfig = [];
... | php | {
"resource": ""
} |
q248308 | AccountingListener.getAccountingFromEvent | validation | protected function getAccountingFromEvent(ResourceEventInterface $event)
{
$resource = $event->getResource();
if (!$resource instanceof AccountingInterface) {
throw new InvalidArgumentException('Expected instance of ' . AccountingInterface::class);
}
return $resource;
... | php | {
"resource": ""
} |
q248309 | Units.getUnits | validation | static function getUnits()
{
return [
static::PIECE,
// Length
static::METER,
static::CENTIMETER,
static::MILLIMETER,
static::INCH,
static::FOOT,
// Weight
static::KILOGRAM,
static::GRAM,
... | php | {
"resource": ""
} |
q248310 | Units.isValid | validation | static function isValid($unit, $throw = false)
{
if (in_array($unit, static::getUnits(), true)) {
return true;
}
if ($throw) {
throw new InvalidArgumentException("Invalid unit '$unit'.");
}
return false;
} | php | {
"resource": ""
} |
q248311 | Units.round | validation | static function round($value, $unit = 'piece')
{
if (0 < $precision = static::getPrecision($unit)) {
$divider = pow(10, $precision);
return round(floor($value * $divider) / $divider, $precision);
}
return floor($value);
} | php | {
"resource": ""
} |
q248312 | TicketAttachmentEventListener.updateMessage | validation | protected function updateMessage(TicketMessageInterface $message)
{
$message->setUpdatedAt(new \DateTime());
$this->persistenceHelper->persistAndRecompute($message, true);
} | php | {
"resource": ""
} |
q248313 | TicketAttachmentEventListener.getAttachmentFromEvent | validation | protected function getAttachmentFromEvent(ResourceEventInterface $event)
{
$attachment = $event->getResource();
if (!$attachment instanceof TicketAttachmentInterface) {
throw new UnexpectedValueException("Expected instance of " . TicketAttachmentInterface::class);
}
ret... | php | {
"resource": ""
} |
q248314 | StockUnitStates.isBetterAvailability | validation | static public function isBetterAvailability($stateA, $stateB)
{
if ($stateA === $stateB) {
return false;
}
switch ($stateA) {
// 'pending' is better than 'new' or 'closed'
case static::STATE_PENDING:
return in_array($stateB, [static::STATE... | php | {
"resource": ""
} |
q248315 | EcNvpConvertAction.addSaleDetails | validation | private function addSaleDetails(array &$details, Model\SaleInterface $sale)
{
if ($sale->getCurrency()->getCode() !== $this->currency) {
return;
}
if (0 !== Money::compare($sale->getGrandTotal(), $details['PAYMENTREQUEST_0_AMT'], $this->currency)) {
return;
}... | php | {
"resource": ""
} |
q248316 | EcNvpConvertAction.addItemDetails | validation | private function addItemDetails(array &$details, Model\SaleItemInterface $item)
{
$total = 0;
if (!($item->isCompound() && !$item->hasPrivateChildren())) {
$itemResult = $item->getResult();
$details['L_PAYMENTREQUEST_0_NAME' . $this->line] = $item->getTotalQuantity() . 'x '... | php | {
"resource": ""
} |
q248317 | EcNvpConvertAction.addDiscountDetails | validation | private function addDiscountDetails(array &$details, Model\SaleAdjustmentInterface $discount)
{
$discountResult = $discount->getResult();
$details['L_PAYMENTREQUEST_0_NAME' . $this->line] = $discount->getDesignation();
$details['L_PAYMENTREQUEST_0_AMT' . $this->line] = '-' . $this->format($... | php | {
"resource": ""
} |
q248318 | SaleDocumentUtil.getSaleEditableDocumentTypes | validation | static public function getSaleEditableDocumentTypes(SaleInterface $sale)
{
$types = [];
foreach (DocumentTypes::getTypes() as $type) {
if (!static::isSaleSupportsDocumentType($sale, $type)) {
continue;
}
foreach ($sale->getAttachments() as $attac... | php | {
"resource": ""
} |
q248319 | SaleDocumentUtil.isSaleSupportsDocumentType | validation | static public function isSaleSupportsDocumentType(SaleInterface $sale, $type)
{
if (!DocumentTypes::isValidType($type)) {
return false;
}
if (empty($classes = DocumentTypes::getClasses($type))) {
return false;
}
foreach ($classes as $class) {
... | php | {
"resource": ""
} |
q248320 | Recipient.getTypes | validation | public static function getTypes()
{
return [
self::TYPE_WEBSITE,
self::TYPE_USER,
self::TYPE_ADMINISTRATOR,
self::TYPE_IN_CHARGE,
self::TYPE_CUSTOMER,
self::TYPE_SALESMAN,
self::TYPE_ACCOUNTABLE,
self::TYPE_SUPPL... | php | {
"resource": ""
} |
q248321 | SaleTransformSubscriber.onPreCopy | validation | public function onPreCopy(SaleTransformEvent $event)
{
$source = $event->getSource();
if ($source instanceof OrderInterface) {
// Prevent if order is not 'new'
if ($source->getState() !== OrderStates::STATE_NEW) {
$event->addMessage(new ResourceMessage(
... | php | {
"resource": ""
} |
q248322 | SaleTransformSubscriber.onPostCopy | validation | public function onPostCopy(SaleTransformEvent $event)
{
$source = $event->getSource();
$target = $event->getTarget();
// Origin number
$target->setOriginNumber($source->getNumber());
// Sample
if ($source instanceof OrderInterface && $target instanceof OrderInterfac... | php | {
"resource": ""
} |
q248323 | Request.uri | validation | public function uri($uri = NULL): string {
if ($uri === NULL) {
return empty($this->_uri) ? '/' : $this->_uri;
}
return $this->_uri = $uri;
} | php | {
"resource": ""
} |
q248324 | Request.method | validation | public function method($method = NULL) {
if ($method === NULL) {
// Act as a getter
return $this->_method;
}
// Act as a setter
$this->_method = strtoupper($method);
return $this;
} | php | {
"resource": ""
} |
q248325 | Request.delete_cookie | validation | public function delete_cookie($name) {
// Remove the cookie
unset($_COOKIE[$name]);
// Nullify the cookie and make it expire
return setcookie($name, null, -86400, $this->cookie_path, $this->cookie_domain, $this->cookie_secure, $this->cookie_httponly);
} | php | {
"resource": ""
} |
q248326 | ManyToManyRelationRecordsFormInput.setDbQueryConditionsForDefaultOptionsLoader | validation | public function setDbQueryConditionsForDefaultOptionsLoader($conditonsAndOptions) {
if (
!is_array($conditonsAndOptions)
&& !($conditonsAndOptions instanceof DbExpr)
&& !($conditonsAndOptions instanceof \Closure)
) {
throw new \InvalidArgumentException(
... | php | {
"resource": ""
} |
q248327 | ManyToManyRelationRecordsFormInput.setOptionLabelColumnForDefaultOptionsLoader | validation | public function setOptionLabelColumnForDefaultOptionsLoader($columnNameOrClosure) {
if (
!is_string($columnNameOrClosure)
&& !($columnNameOrClosure instanceof DbExpr)
&& !($columnNameOrClosure instanceof \Closure)
) {
throw new \InvalidArgumentException(
... | php | {
"resource": ""
} |
q248328 | ResetsPasswordsViaAccessKey.loadFromPasswordRecoveryAccessKey | validation | static public function loadFromPasswordRecoveryAccessKey(string $accessKey) {
try {
$data = \Crypt::decrypt($accessKey);
} catch (DecryptException $exc) {
return false;
}
if (empty($data)) {
return false;
}
$data = json_decode($data, tr... | php | {
"resource": ""
} |
q248329 | Router.error | validation | public function error(Callable $action = null)
{
if ($action) $this->errorAction = $action;
return $this->errorAction;
} | php | {
"resource": ""
} |
q248330 | Router.defaultHeader | validation | public function defaultHeader(array $headers = [])
{
$this->defaultHeaders = array_merge($this->defaultHeaders, $headers);
return $this->defaultHeaders;
} | php | {
"resource": ""
} |
q248331 | Router.removeDefaultHeader | validation | public function removeDefaultHeader($headers = "")
{
foreach ($headers as $header)
foreach ($this->defaultHeaders as $h => $v)
if ($header === $h) unset($this->defaultHeaders[$h]);
return $this->defaultHeaders;
} | php | {
"resource": ""
} |
q248332 | Router.match | validation | protected function match(Request $request)
{
foreach ($this->routes as $route)
{
if ($route->method() === $request->method() && $route->match($request->url()))
{
if ($action = $route->action())
{
try
{
$response = $action($request, $route->args());
if ($response !== f... | php | {
"resource": ""
} |
q248333 | Router.add | validation | protected function add($url, $method, Callable $action)
{
$url = $this->base !== "" && $url === "/" ? $this->base : $this->base.$url;
$route = new Route($url, $method, $action);
$this->routes[] = $route;
return $route;
} | php | {
"resource": ""
} |
q248334 | InvoiceValidator.checkHierarchyIntegrity | validation | private function checkHierarchyIntegrity(InvoiceInterface $invoice)
{
// [ Invoice <-> Sale <-> Shipment ] integrity
if (null !== $shipment = $invoice->getShipment()) {
if ($invoice->getSale() !== $shipment->getSale()) {
throw new ValidationFailedException();
... | php | {
"resource": ""
} |
q248335 | AbstractSaleItemListener.loadItem | validation | private function loadItem(Model\SaleItemInterface $item)
{
$item->getAdjustments()->toArray();
$children = $item->getChildren()->toArray();
foreach ($children as $child) {
$this->loadItem($child);
}
} | php | {
"resource": ""
} |
q248336 | AbstractSaleItemListener.throwIllegalOperationIfItemIsImmutable | validation | private function throwIllegalOperationIfItemIsImmutable(ResourceEventInterface $event)
{
if ($event->getHard()) {
return;
}
$item = $this->getSaleItemFromEvent($event);
// Stop if item is immutable.
if ($item->isImmutable()) {
throw new IllegalOperat... | php | {
"resource": ""
} |
q248337 | Blocks.get | validation | public function get(string $name): Block {
if (isset($this->_blocks[$name]))
return $this->_blocks[$name];
$this->_blocks[$name] = new $this->block_class($name);
return $this->_blocks[$name];
} | php | {
"resource": ""
} |
q248338 | SubjectNormalizerHelper.normalizeStock | validation | public function normalizeStock(StockSubjectInterface $subject, $format = null, array $context = [])
{
$translator = $this->constantHelper->getTranslator();
$formatter = $this->getFormatter();
if (null !== $eda = $subject->getEstimatedDateOfArrival()) {
$eda = $formatter->date($e... | php | {
"resource": ""
} |
q248339 | SubjectNormalizerHelper.findStockUnits | validation | private function findStockUnits(StockSubjectInterface $subject)
{
/** @var StockUnitRepositoryInterface $repository */
$repository = $this->entityManager->getRepository($subject::getStockUnitClass());
/** @var StockUnitInterface[] $stockUnits */
$stockUnits = array_merge(
... | php | {
"resource": ""
} |
q248340 | PrioritizeHelper.ceilComparison | validation | private function ceilComparison(UnitCandidate $a, UnitCandidate $b, $property, $quantity)
{
if ($a->{$property} >= $quantity && $b->{$property} < $quantity) {
return -1;
}
if ($a->{$property} < $quantity && $b->{$property} >= $quantity) {
return 1;
}
... | php | {
"resource": ""
} |
q248341 | PrioritizeHelper.equalComparison | validation | private function equalComparison(UnitCandidate $a, UnitCandidate $b, $property, $quantity)
{
if ($a->{$property} == $quantity && $b->{$property} != $quantity) {
return -1;
}
if ($a->{$property} != $quantity && $b->{$property} == $quantity) {
return 1;
}
... | php | {
"resource": ""
} |
q248342 | DocumentTypes.getClasses | validation | static public function getClasses($type)
{
switch ($type) {
case static::TYPE_FORM:
return [CartInterface::class];
case static::TYPE_QUOTE:
return [QuoteInterface::class];
case static::TYPE_PROFORMA:
return [QuoteInterface::... | php | {
"resource": ""
} |
q248343 | URL.site | validation | public static function site(string $uri = '', $protocol = null): string {
// Chop off possible scheme, host, port, user and pass parts
$path = preg_replace('~^[-a-z0-9+.]++://[^/]++/?~', '', trim($uri, '/'));
if (preg_match('/[^\x00-\x7F]/S', $path)) {
// Encode all non-ASCII charac... | php | {
"resource": ""
} |
q248344 | URL.query | validation | public static function query(array $params = null, $use_get = null) {
if ($use_get) {
if ($params === NULL) {
// Use only the current parameters
$params = $_GET;
} else {
// Merge the current and new parameters
$params = Arr... | php | {
"resource": ""
} |
q248345 | URL.title | validation | public static function title($title, $separator = '-', $ascii_only = FALSE) {
if ($ascii_only === TRUE) {
// Transliterate non-ASCII characters
$title = UTF8::transliterate_to_ascii($title);
// Remove all characters that are not the separator, a-z, 0-9, or whitespace
... | php | {
"resource": ""
} |
q248346 | Config.onParse | validation | public function onParse($finalText) {
// if a specific post-parse function was defined, it is called
$func = $this->getParam('postParseFunction');
if (isset($func))
$finalText = $func($finalText);
// add footnotes' content if needed
if ($this->getParam('addFootnotes')) {
$footnotes = $this->getFootnotes... | php | {
"resource": ""
} |
q248347 | PaymentCalculator.calculateTotalByState | validation | protected function calculateTotalByState(PaymentSubjectInterface $subject, $state)
{
PaymentStates::isValidState($state, true);
$currency = $subject->getCurrency()->getCode();
$total = 0;
foreach ($subject->getPayments() as $payment) {
if ($payment->getState() === $sta... | php | {
"resource": ""
} |
q248348 | Money.round | validation | static public function round($amount, $currency)
{
$precision = static::getPrecision($currency);
$roundingIncrement = static::getRoundingIncrement($currency);
$amount = round($amount, $precision, \PHP_ROUND_HALF_EVEN);
if (0 < $roundingIncrement && 0 < $precision) {
$ro... | php | {
"resource": ""
} |
q248349 | Money.getPrecision | validation | static public function getPrecision($currency)
{
if (isset(static::$precisions[$currency])) {
return static::$precisions[$currency];
}
return static::$precisions[$currency] = static::getCurrencyBundle()->getFractionDigits($currency);
} | php | {
"resource": ""
} |
q248350 | Money.getRoundingIncrement | validation | static public function getRoundingIncrement($currency)
{
if (isset(static::$increments[$currency])) {
return static::$increments[$currency];
}
return static::$increments[$currency] = static::getCurrencyBundle()->getRoundingIncrement($currency);
} | php | {
"resource": ""
} |
q248351 | TicketEventListener.getTicketFromEvent | validation | protected function getTicketFromEvent(ResourceEventInterface $event)
{
$ticket = $event->getResource();
if (!$ticket instanceof TicketInterface) {
throw new UnexpectedValueException("Expected instance of " . TicketInterface::class);
}
return $ticket;
} | php | {
"resource": ""
} |
q248352 | StockAdjustmentReasons.isValidReason | validation | static public function isValidReason($reason, $throw = true)
{
if (in_array($reason, static::getReasons(), true)) {
return true;
}
if ($throw) {
throw new InvalidArgumentException("Invalid stock adjustment reason.");
}
return false;
} | php | {
"resource": ""
} |
q248353 | AuthActions.isAuthorized | validation | public function isAuthorized($user, $plugin, $controller, $action) {
$isAuthorized = false;
if ($plugin) {
$plugin = Inflector::camelize($plugin);
}
if ($this->isPublicAction($plugin, $controller, $action)) {
$isAuthorized = true;
} elseif (isset($user['role']) && !empty($controller) && !empty($action... | php | {
"resource": ""
} |
q248354 | AuthActions.urlAllowed | validation | public function urlAllowed($user, $url) {
if (empty($url)) {
return false;
}
if (is_array($url)) {
// prevent plugin confusion
$url = Hash::merge([
'plugin' => null
], $url);
$url = Router::url($url);
// strip off the base path
$url = Router::normalize($url);
}
$route = Router::pars... | php | {
"resource": ""
} |
q248355 | StockSubjectModes.isBetterMode | validation | static public function isBetterMode($modeA, $modeB)
{
// TODO Find something more explicit than 'better' (availability ?)
// TODO assert valid states ?
if ($modeA === static::MODE_DISABLED) {
return $modeB !== static::MODE_DISABLED;
} elseif ($modeA === static::MODE_JUS... | php | {
"resource": ""
} |
q248356 | AbstractSaleRepository.getOneQueryBuilder | validation | protected function getOneQueryBuilder($alias = null, $indexBy = null)
{
return $this
->createQueryBuilder($alias, $indexBy)
->select(
$alias,
'customer',
'customer_group',
'invoice_address',
'delivery_add... | php | {
"resource": ""
} |
q248357 | OutstandingWatcher.watch | validation | public function watch(Repository\PaymentRepositoryInterface $paymentRepository)
{
if (null === $term = $this->termRepository->findLongest()) {
return false;
}
$today = new \DateTime();
$today->setTime(0, 0, 0);
$fromDate = clone $today;
$fromDate->modify... | php | {
"resource": ""
} |
q248358 | SupplierProductRepository.getFindBySubjectQuery | validation | protected function getFindBySubjectQuery()
{
if (null !== $this->findBySubjectQuery) {
return $this->findBySubjectQuery;
}
$qb = $this->createFindBySubjectQueryBuilder();
return $this->findBySubjectQuery = $qb->getQuery();
} | php | {
"resource": ""
} |
q248359 | SupplierProductRepository.getGetAvailableSumBySubjectQuery | validation | protected function getGetAvailableSumBySubjectQuery()
{
if (null !== $this->getAvailableSumBySubjectQuery) {
return $this->getAvailableSumBySubjectQuery;
}
$as = $this->getAlias();
$qb = $this->createFindBySubjectQueryBuilder();
$qb
->andWhere($qb->e... | php | {
"resource": ""
} |
q248360 | SupplierProductRepository.getGetMinEdaBySubjectQuery | validation | protected function getGetMinEdaBySubjectQuery()
{
if (null !== $this->getMinEdaBySubjectQuery) {
return $this->getMinEdaBySubjectQuery;
}
$as = $this->getAlias();
$qb = $this->createFindBySubjectQueryBuilder();
$qb
->andWhere($qb->expr()->isNotNull($... | php | {
"resource": ""
} |
q248361 | SupplierProductRepository.getFindBySubjectAndSupplierQuery | validation | protected function getFindBySubjectAndSupplierQuery()
{
if (null !== $this->findBySubjectAndSupplierQuery) {
return $this->findBySubjectAndSupplierQuery;
}
$qb = $this->createFindBySubjectQueryBuilder();
return $this->findBySubjectAndSupplierQuery = $qb
->an... | php | {
"resource": ""
} |
q248362 | SupplierProductRepository.createFindBySubjectQueryBuilder | validation | private function createFindBySubjectQueryBuilder()
{
$as = $this->getAlias();
$qb = $this->createQueryBuilder();
return $qb
->andWhere($qb->expr()->eq($as . '.subjectIdentity.provider', ':provider'))
->andWhere($qb->expr()->eq($as . '.subjectIdentity.identifier', ':i... | php | {
"resource": ""
} |
q248363 | PeskyCmfLanguageDetectorServiceProvider.detectAndApplyLanguage | validation | protected function detectAndApplyLanguage() {
if ($this->config('autodetect', true)) {
/** @var LanguageDetector $detector */
$detector = $this->getLanguageDetector();
$language = $detector->getLanguageFromCookie();
if (!$language || strlen($language) > 5 || !in_a... | php | {
"resource": ""
} |
q248364 | TicketMessageEventListener.updateTicket | validation | protected function updateTicket(TicketMessageInterface $message)
{
$ticket = $message->getTicket()->setUpdatedAt(new \DateTime());
if ($message->isLatest() && ($ticket->getState() !== TicketStates::STATE_CLOSED)) {
if ($message->isCustomer()) {
if ($ticket->getState() ==... | php | {
"resource": ""
} |
q248365 | TicketMessageEventListener.getMessageFromEvent | validation | protected function getMessageFromEvent(ResourceEventInterface $event)
{
$message = $event->getResource();
if (!$message instanceof TicketMessageInterface) {
throw new UnexpectedValueException("Expected instance of " . TicketMessageInterface::class);
}
return $message;
... | php | {
"resource": ""
} |
q248366 | AddressUtil.equals | validation | static public function equals(AddressInterface $source, AddressInterface $target)
{
if (!($source->getCompany() === $target->getCompany()
&& $source->getGender() === $target->getGender()
&& $source->getFirstName() === $target->getFirstName()
&& $source->getLastName() === ... | php | {
"resource": ""
} |
q248367 | AddressUtil.copy | validation | static public function copy(AddressInterface $source, AddressInterface $target)
{
$target
->setCompany($source->getCompany())
->setGender($source->getGender())
->setFirstName($source->getFirstName())
->setLastName($source->getLastName())
->setStree... | php | {
"resource": ""
} |
q248368 | VatNumberResult.getDetails | validation | public function getDetails()
{
return [
'valid' => $this->valid,
'country' => $this->country,
'number' => $this->number,
'name' => $this->name,
'address' => $this->address,
'date' => $this->date,
];
} | php | {
"resource": ""
} |
q248369 | OpeningHour.addRanges | validation | public function addRanges(string $from, string $to)
{
$this->ranges[] = [
'from' => $from,
'to' => $to,
];
return $this;
} | php | {
"resource": ""
} |
q248370 | NotifiableTrait.hasNotifications | validation | public function hasNotifications($type = null)
{
if (null !== $type) {
NotificationTypes::isValidType($type);
return $this->getNotifications($type)->count();
}
return 0 < $this->notifications->count();
} | php | {
"resource": ""
} |
q248371 | NotifiableTrait.getNotifications | validation | public function getNotifications($type = null)
{
if (null !== $type) {
NotificationTypes::isValidType($type);
return $this
->notifications
->filter(function (NotificationInterface $n) use ($type) {
return $n->getType() === $type;
... | php | {
"resource": ""
} |
q248372 | SupplierOrderListener.updateTotals | validation | protected function updateTotals(SupplierOrderInterface $order)
{
$changed = false;
$tax = $this->calculator->calculatePaymentTax($order);
if ($tax != $order->getTaxTotal()) {
$order->setTaxTotal($tax);
$changed = true;
}
$payment = $this->calculator-... | php | {
"resource": ""
} |
q248373 | SupplierOrderListener.updateExchangeRate | validation | protected function updateExchangeRate(SupplierOrderInterface $order)
{
// TODO Remove when supplier order payments will be implemented.
if (null !== $order->getExchangeRate()) {
return false;
}
if (!SupplierOrderStates::isStockableState($order->getState())) {
... | php | {
"resource": ""
} |
q248374 | SupplierOrderListener.getSupplierOrderFromEvent | validation | protected function getSupplierOrderFromEvent(ResourceEventInterface $event)
{
$order = $event->getResource();
if (!$order instanceof SupplierOrderInterface) {
throw new InvalidArgumentException("Expected instance of SupplierOrderInterface.");
}
return $order;
} | php | {
"resource": ""
} |
q248375 | InvoiceBuilder.findOrCreateGoodLine | validation | public function findOrCreateGoodLine(
Invoice\InvoiceInterface $invoice,
Common\SaleItemInterface $item,
$available,
$expected = null
) {
$line = null;
if (0 >= $available) {
return $line;
}
// Existing line lookup
foreach ($invoi... | php | {
"resource": ""
} |
q248376 | Margin.getPercent | validation | public function getPercent(): float
{
$amount = $this->getAmount();
if (0 < $this->sellingPrice) {
return round($amount * 100 / $this->sellingPrice, 2);
}
return 0;
} | php | {
"resource": ""
} |
q248377 | Margin.merge | validation | public function merge(Margin $margin): void
{
$this->purchaseCost += $margin->getPurchaseCost();
$this->sellingPrice += $margin->getSellingPrice();
$this->average = $this->average || $margin->isAverage();
} | php | {
"resource": ""
} |
q248378 | DefaultNumberGenerator.readNumber | validation | private function readNumber()
{
// Open
if (false === $this->handle = fopen($this->filePath, 'c+')) {
throw new RuntimeException("Failed to open file {$this->filePath}.");
}
// Exclusive lock
if (!flock($this->handle, LOCK_EX)) {
throw new RuntimeExcep... | php | {
"resource": ""
} |
q248379 | SaleStepValidator.getConstraintsForStep | validation | protected function getConstraintsForStep($step)
{
$constraints = [new Valid()];
if ($step === static::SHIPMENT_STEP) {
$constraints[] = new Constraints\SaleShipmentStep();
}
if ($step === static::PAYMENT_STEP) {
$constraints[] = new Constraints\SaleShipmentS... | php | {
"resource": ""
} |
q248380 | SaleStepValidator.getGroupsForStep | validation | protected function getGroupsForStep($step)
{
$groups = ['Default'];
if ($step === static::CHECKOUT_STEP) {
$groups[] = 'Checkout';
$groups[] = 'Identity';
$groups[] = 'Availability';
} elseif ($step === static::SHIPMENT_STEP) {
$groups[] = 'Av... | php | {
"resource": ""
} |
q248381 | SupplierDeliveryItemListener.handleQuantityChange | validation | protected function handleQuantityChange(SupplierDeliveryItemInterface $item)
{
$changeSet = $this->persistenceHelper->getChangeSet($item);
// Delta quantity (difference between new and old)
if (null === $orderItem = $item->getOrderItem()) {
throw new RuntimeException("Failed to ... | php | {
"resource": ""
} |
q248382 | PayumBuilderPass.registerFactories | validation | private function registerFactories(ContainerBuilder $container)
{
$defaultConfig = [];
$builder = $container->getDefinition('payum.builder');
$builder->addMethodCall('addGatewayFactoryConfig', [
Offline\Constants::FACTORY_NAME,
$defaultConfig,
]);
$b... | php | {
"resource": ""
} |
q248383 | PayumBuilderPass.registerActions | validation | private function registerActions(ContainerBuilder $container)
{
// Payzen convert action
if (class_exists('Ekyna\Component\Payum\Payzen\PayzenGatewayFactory')) {
// Convert action
$definition = new Definition('Ekyna\Component\Commerce\Bridge\Payum\Payzen\Action\ConvertAction'... | php | {
"resource": ""
} |
q248384 | StockAssignmentDispatcher.sortAssignments | validation | private function sortAssignments(array $assignments, $direction = SORT_DESC)
{
usort($assignments, function (StockAssignmentInterface $a, StockAssignmentInterface $b) use ($direction) {
$aDate = $a->getSaleItem()->getSale()->getCreatedAt();
$bDate = $b->getSaleItem()->getSale()->getC... | php | {
"resource": ""
} |
q248385 | Iac_Profile_Settings.remove_author_meta_values | validation | public static function remove_author_meta_values() {
global $blog_id;
if ( isset( $blog_id ) && ! empty( $blog_id ) ) {
$blogusers = get_users( array( 'blog_id' => $blog_id ) );
foreach ( $blogusers as $user_object ) {
delete_user_meta( $user_object->ID, 'post_subscription' );
delete_user_meta( $user... | php | {
"resource": ""
} |
q248386 | Iac_Profile_Settings.add_custom_profile_fields | validation | public function add_custom_profile_fields( $user ) {
$user_settings = apply_filters( 'iac_get_user_settings', array(), $user->ID );
$nonce = wp_create_nonce( 'iac_user_settings' );
?>
<h3><?php _e( 'Informer?', $this->get_textdomain() ); ?></h3>
<table class="form-table">
<tr id="post_subscription... | php | {
"resource": ""
} |
q248387 | Iac_Profile_Settings.save_custom_profile_fields | validation | public function save_custom_profile_fields( $user_id ) {
if ( 'POST' !== $_SERVER[ 'REQUEST_METHOD' ] || ! isset( $_POST[ 'iac_nonce' ] ) ) {
return;
}
if ( ! wp_verify_nonce( $_POST[ 'iac_nonce' ], 'iac_user_settings' ) ) {
return;
}
do_action(
'iac_save_user_settings',
$user_id,
isset( $_PO... | php | {
"resource": ""
} |
q248388 | Iac_Profile_Settings.get_user_settings | validation | public function get_user_settings( $default = array(), $user_id = NULL ) {
if ( ! $user_id )
return $default;
$default_opt_in = apply_filters( 'iac_default_opt_in', FALSE );
$default = $default_opt_in
? '1'
: '0';
$settings = array(
'inform_about_posts' => get_user_meta( $user_id, 'post_subscr... | php | {
"resource": ""
} |
q248389 | Price.getTotal | validation | public function getTotal($discounted = true)
{
$base = $this->base;
if ($discounted && $this->hasDiscounts()) {
foreach ($this->discounts as $discount) {
$base -= $this->calculateAdjustment($discount, $base);
}
}
$total = $base;
if (... | php | {
"resource": ""
} |
q248390 | Price.calculateAdjustment | validation | private function calculateAdjustment(AdjustmentDataInterface $adjustment, $base)
{
if ($adjustment->getMode() === AdjustmentModes::MODE_PERCENT) {
return Money::round($base * $adjustment->getAmount() / 100, $this->currency);
}
if ($adjustment->getMode() === AdjustmentModes::MODE... | php | {
"resource": ""
} |
q248391 | SubjectIdentity.clear | validation | public function clear()
{
$this->provider = null;
$this->identifier = null;
$this->subject = null;
} | php | {
"resource": ""
} |
q248392 | SubjectIdentity.equals | validation | public function equals(SubjectIdentity $identity)
{
return $this->provider === $identity->getProvider()
&& $this->identifier === $identity->getIdentifier();
} | php | {
"resource": ""
} |
q248393 | SubjectIdentity.copy | validation | public function copy(SubjectIdentity $identity)
{
$this->provider = $identity->getProvider();
$this->identifier = $identity->getIdentifier();
} | php | {
"resource": ""
} |
q248394 | ACL.add_rule | validation | public function add_rule($access, $role, $action): void {
$roles = (array)$role;
foreach ($roles as $r) {
$action = (array)$action;
foreach ($action as $a) {
$this->_rules[$r][$a] = $access;
}
}
} | php | {
"resource": ""
} |
q248395 | ACL.match | validation | protected function match($role, $action): bool {
$roles = $actions = ['*'];
$allow = false;
if ($role != '*')
array_unshift($roles, $role);
if ($action != '*')
array_unshift($actions, $action);
// Ищем наиболее подходящее правило. Идем от частного к общ... | php | {
"resource": ""
} |
q248396 | StockSubjectUpdater.nullDateIfLowerThanToday | validation | private function nullDateIfLowerThanToday(\DateTime $eda = null)
{
if (null === $eda) {
return null;
}
$today = new \DateTime();
$today->setTime(0, 0, 0);
if ($eda < $today) {
return null;
}
return $eda;
} | php | {
"resource": ""
} |
q248397 | StockSubjectUpdater.setSubjectData | validation | private function setSubjectData(
StockSubjectInterface $subject,
$inStock = .0,
$availableStock = .0,
$virtualStock = .0,
\DateTime $eda = null
) {
$changed = false;
if ($inStock != $subject->getInStock()) { // TODO use packaging format (bccomp for float)
... | php | {
"resource": ""
} |
q248398 | StockSubjectUpdater.setSubjectState | validation | private function setSubjectState(StockSubjectInterface $subject, $state)
{
if ($subject->getStockState() != $state) {
$subject->setStockState($state);
return true;
}
return false;
} | php | {
"resource": ""
} |
q248399 | Expression.compile | validation | public function compile(Database $db = NULL): string {
if ($db === null) {
// Get the database instance
$db = \Mii::$app->db;
}
$value = $this->value();
if (!empty($this->_parameters)) {
// Quote all of the parameter values
$params = arra... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.