called from finish context
saves pdf as file
@param array $cart
352010
private function generateOrderConfirmation($cart)
    {
        
        $this->set('cart', $cart);
        $manufacturers = [];

        $this->Cart = TableRegistry::getTableLocator()->get('Carts');
        $cart = $this->Cart->find('all', [
            'conditions' => [
                'Carts.id_cart' => $cart['Cart']->id_cart,
            ],
            'contain' => [
                'CartProducts.OrderDetails.OrderDetailTaxes',
                'CartProducts.Products',
                'CartProducts.Products.Manufacturers.AddressManufacturers'
            ]
        ])->first();
        
        foreach ($cart->cart_products as $cartProduct) {
            $manufacturers[$cartProduct->product->id_manufacturer] = [
                'CartProducts' => $cart->cart_products,
                'Manufacturer' => $cartProduct->product->manufacturer
            ];
        }
        
        $this->set('manufacturers', $manufacturers);
        $this->set('saveParam', 'I');
        $this->RequestHandler->renderAs($this, 'pdf');
        return $this->render('generateOrderConfirmation');
    }
1146263
public function write($content) : void
    {
        $this->checkFile();
        $this->checkDir();

        file_put_contents($this->path, $content);
    }
1124354
public function dispatchOrderPreCreatedEvent(
        CartInterface $cart
    ) {
        $orderPreCreatedEvent = new OrderPreCreatedEvent($cart);
        $this->eventDispatcher->dispatch(
            ElcodiCartEvents::ORDER_PRECREATED,
            $orderPreCreatedEvent
        );
    }
1052829
protected function finishSave(array $options)
    {
        $this->fireModelEvent('saved', false);

        if ($this->isDirty() && ($options['touch'] ?? true)) {
            $this->touchOwners();
        }

        $this->syncOriginal();
    }
19194
public function persist($document)
    {
        $documentArray = $this->converter->convertToArray($document);
        $type = $this->getMetadataCollector()->getDocumentType(get_class($document));

        $this->bulk('index', $type, $documentArray);
    }
540196
def save_as_pdf(self, dest_path):
        
        dest_path = self._add_extension('pdf', dest_path)
        build_dir = tempfile.mkdtemp()
        build_path = os.path.join(build_dir, 'document.tex')
        self.save_assets(build_path)
        with open(build_path, 'w') as f:
            f.write(self.render())
        pdf_path = self._build_document(build_path)
        shutil.copyfile(pdf_path, dest_path)
        shutil.rmtree(build_dir)
1336432
public function moveTo(Cart $cart){
        $model = null;
        \DB::transaction(function () use($cart, &$model) {
            $this->delete(); // delete from own cart
            $attr = $this->attributes;
            unset($attr['cart_id']);
            $model = $cart->items()->create($attr);
        });
        return $model;
    }
778588
public function saveToDisk($file = null)
    {
        if ($file !== null && is_string($file)) {
            if (file_exists($file) && !(is_file($file) && is_writable($file))) {
                throw new OdfException('Permission denied : can\'t create ' . $file);
            }
            $this->_save();
            copy($this->tmpfile, $file);
        } else {
            $this->_save();
        }
    }
666173
private static function saveToFile($path, $contents)
    {
        $directory = pathinfo($path, PATHINFO_DIRNAME);
        if (!file_exists($directory)) {
            mkdir($directory, 0777, true);
        }
        file_put_contents($path, $contents);
    }
102412
public function saveAs($name)
    {
        if (!$this->getCommand()->getExecuted() && !$this->execute()) {
            return false;
        }
        $tmpFile = (string) $this->getTmpFile();
        if (!copy($tmpFile, $name)) {
            $this->_error = "Could not copy PDF from tmp location '$tmpFile' to '$name'";
            return false;
        }
        return true;
    }
1076134
function closeObject() {
		//Helpers::dompdf_debug("trace", "Enter My_TCPDF.closeObject(state = $this->state)");
		if ($this->dompdf_num_stack > 0) {

			if ($this->state == 2) {
				$curr_buffer = $this->getPageBuffer($this->page);
			}
			else {
				$curr_buffer = $this->getBuffer();
			}

			$this->dompdf_objects[$this->dompdf_num_objects]['c'] = $curr_buffer;
			$this->dompdf_objects[$this->dompdf_num_objects]['p'] = $this->page;
			$this->dompdf_objects[$this->dompdf_num_objects]['g'] = $this->getGraphicVars();

			//Helpers::dompdf_debug("trace", "--------- OBJECT buffer -------> " . $curr_buffer);

			$saved_stack = $this->dompdf_stack[$this->dompdf_num_stack];

			//Helpers::dompdf_debug("trace", "--------- saved buffer -------> " . $saved_stack['c']);

			if ($this->state == 2) {
				$this->setPageBuffer($this->page, $saved_stack['c']);
			}
			else {
				$this->buffer = $saved_stack['c'];
				$this->bufferlen = strlen($this->buffer);
			}
			$this->page = $saved_stack['p'];
			$this->setGraphicVars($saved_stack['g']);

			unset($this->dompdf_stack[$this->dompdf_num_stack]);
			$this->dompdf_num_stack--;
		}
	}
644324
public function setSessionCart(Cart $cart = null)
    {
        if (null === $cart || $cart->isNew()) {
            self::$transientCart = $cart;
            $this->remove("thelia.cart_id");
        } else {
            self::$transientCart = null;
            $this->set("thelia.cart_id", $cart->getId());
        }

        return $this;
    }
329194
private function saveFile(): void
    {
        $sourceCode = Helpers::tabsToSpaces((string) $this->entityFile);
        $entityPath = dirname(__DIR__, 7) . '/src/' . $this->entityData['namespace'] . '/';

        $handle = fopen($entityPath . $this->entityData['class'] . '.php', 'w');
        fwrite($handle, $sourceCode);
        fclose($handle);
    }
581096
public function saveApplicationPaths(array $paths)
  {
      foreach ($paths as $key => $value) {
          $this->applyInstance("path.$key", realpath($value));
      }
  }
910766
public function write ($content)
	{
		$this->createPath($this->path);
		file_put_contents($this->getName(), $content, FILE_APPEND);
	}
1128635
private function _save()
    {
        $this->file->open($this->tmpfile);
        $this->_parse();
        if (!$this->file->addFromString('content.xml', $this->contentXml) || !$this->file->addFromString('styles.xml', $this->stylesXml)) {
            throw new OdfException('Error during file export addFromString');
        }
        $lastpos=strrpos($this->manifestXml, "\n", -15); //find second last newline in the manifest.xml file
        $manifdata = "";

        //Enter all images description in $manifdata variable
        foreach ($this->manif_vars as $val) {
            $ext = substr(strrchr($val, '.'), 1);
            $manifdata = $manifdata.'<manifest:file-entry manifest:media-type="image/'.$ext.'" manifest:full-path="Pictures/'.$val.'"/>'."\n";
        }
        //Place content of $manifdata variable in manifest.xml file at appropriate place
        $this->manifestXml = substr_replace($this->manifestXml, "\n".$manifdata, $lastpos+1, 0);
        //$this->manifestXml = $this->manifestXml ."\n".$manifdata;

        if (! $this->file->addFromString('META-INF/manifest.xml', $this->manifestXml)) {
            throw new OdfException('Error during manifest file export');
        }
        foreach ($this->images as $imageKey => $imageValue) {
            $this->file->addFile($imageKey, 'Pictures/' . $imageValue);
        }
        $this->file->close(); // seems to bug on windows CLI sometimes
    }
871937
public function save($content)
    {
        $content = $this->_getHeader() . $content;
        $result  = file_put_contents($this->_resultFile, $content);

        if (!$result) {
            throw new Exception('JBZoo/Less: File not save - ' . $this->_resultFile); // @codeCoverageIgnore
        }
    }