1. Go to this page and download the library: Download var-lab/lexoffice-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use VarLabIT\LexofficeBundle\Entity\Address;
use VarLabIT\LexofficeBundle\Entity\Company as LexofficeCompany;
use VarLabIT\LexofficeBundle\Entity\Contact;
use VarLabIT\LexofficeBundle\Entity\ContactRole;
use VarLabIT\LexofficeBundle\Entity\Enum\AddressType;
use VarLabIT\LexofficeBundle\Entity\Enum\RoleType;
use VarLabIT\LexofficeBundle\Entity\Person;
use VarLabIT\LexofficeBundle\LexofficeClient;
class CityPageController extends AbstractController {
public function __construct(
private readonly CompanyRepository $companyRepository,
private readonly LexofficeClient $lexofficeClient,
)
{
}
private function getContactObject(Company $company): Contact
{
$contact = new Contact();
$contact
->setVersion(0)
->addRole(RoleType::CUSTOMER, new ContactRole())
->setCompany(
(new LexofficeCompany())
->setName($company->getName())
->addContactPerson(
(new Person())
->setFirstName($company->getGivenName())
->setLastName($company->getFamilyName())
->setEmailAddress($company->getInvoiceEmail())
->setPrimary(true)
->setPhoneNumber($company->getContactPhone())
),
)
->addAddress(
AddressType::BILLING,
(new Address())
->setSupplement('Rechnungsadresse')
->setStreet($company->getAddress())
->setZip($company->getZipcode())
->setCity($company->getCity())
->setCountryCode($company->getCountry())
);
return $contact;
}
public function createContact(int $companyId): Response {
$company = $this->companyRepository->find($companyId);
$contact = $this->createContact($company);
$contact = $this->lexofficeClient->createContact($contact);
$company
->setVersion($contact->getVersion())
->setLexofficeId($contact->getId());
}
}
public function createContact(int $companyId): Response {
$company = $this->companyRepository->find($companyId);
$contact = $this->createContact($company);
$contact = $this->lexofficeClient->updateContact($contact);
$company
->setVersion($contact->getVersion())
->setLexofficeId($contact->getId());
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.