PHP code example of tourze / supplier-manage-bundle
1. Go to this page and download the library: Download tourze/supplier-manage-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 Tourze\SupplierManageBundle\Service\SupplierService;
use Tourze\SupplierManageBundle\Enum\SupplierType;
use Tourze\SupplierManageBundle\Enum\CooperationModel;
class SupplierController
{
public function __construct(
private readonly SupplierService $supplierService
) {}
public function createSupplier(): Supplier
{
return $this->supplierService->create([
'name' => 'Example Supplier',
'legalName' => 'Example Supplier Co., Ltd.',
'legalAddress' => 'Beijing Chaoyang District xxx Street',
'registrationNumber' => '91110000000000000X',
'taxNumber' => '91110000000000000X',
'supplierType' => SupplierType::GENERAL,
'cooperationModel' => CooperationModel::LONG_TERM,
'contactPerson' => 'John Doe',
'contactPhone' => '13800138000',
'contactEmail' => '[email protected]',
'bankName' => 'Bank of China',
'bankAccount' => '6210000000000000000'
]);
}
}
use Tourze\SupplierManageBundle\Repository\SupplierRepository;
class SupplierController
{
public function __construct(
private readonly SupplierRepository $supplierRepository
) {}
public function findSupplier(int $id): ?Supplier
{
return $this->supplierRepository->find($id);
}
public function searchSuppliers(string $keyword): array
{
return $this->supplierRepository->findByName($keyword);
}
}
use Tourze\SupplierManageBundle\Entity\SupplierContact;
use Tourze\SupplierManageBundle\Repository\SupplierContactRepository;
class ContactController
{
public function createContact(Supplier $supplier): SupplierContact
{
$contact = new SupplierContact();
$contact->setSupplier($supplier);
$contact->setName('Jane Smith');
$contact->setPosition('Sales Manager');
$contact->setPhone('13900139000');
$contact->setEmail('[email protected]');
$contact->setIsPrimary(true);
return $contact;
}
}
bash
# Run all tests
php bin/phpunit packages/supplier-manage-bundle/tests/
# Run specific tests
php bin/phpunit packages/supplier-manage-bundle/tests/Service/SupplierServiceTest.php
# Generate test coverage report
php bin/phpunit --coverage-html coverage packages/supplier-manage-bundle/tests/
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.