示例#1
0
 /**
  * Adds or replaces the attribute item in the list of service attributes.
  *
  * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface $item Service attribute item
  * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
  */
 public function setAttributeItem(\Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface $item)
 {
     $this->getAttributeMap();
     $type = $item->getType();
     $code = $item->getCode();
     if (!isset($this->attributesMap[$type][$code])) {
         $this->attributesMap[$type][$code] = $item;
         $this->attributes[] = $item;
     }
     $this->attributesMap[$type][$code]->setValue($item->getValue());
     $this->setModified();
     return $this;
 }
示例#2
0
 protected function addDownload(\Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface $item)
 {
     $fs = $this->getContext()->getFilesystemManager()->get('fs-secure');
     $response = $this->getView()->response();
     $value = (string) $item->getValue();
     if ($fs->has($value)) {
         $name = $item->getName();
         if (pathinfo($name, PATHINFO_EXTENSION) == null && ($ext = pathinfo($value, PATHINFO_EXTENSION)) != null) {
             $name .= '.' . $ext;
         }
         $response->withHeader('Content-Description', 'File Transfer');
         $response->withHeader('Content-Type', 'application/octet-stream');
         $response->withHeader('Content-Disposition', 'attachment; filename="' . $name . '"');
         $response->withHeader('Content-Length', $fs->size($value));
         $response->withHeader('Cache-Control', 'must-revalidate');
         $response->withHeader('Pragma', 'private');
         $response->withHeader('Expires', 0);
         $response->withBody($response->createStream($fs->reads($value)));
     } elseif (filter_var($value, FILTER_VALIDATE_URL) !== false) {
         $response->withHeader('Location', $value);
         $response->withStatus(303);
     } else {
         $response->withStatus(404);
     }
 }