clean install

This commit is contained in:
2024-12-10 15:08:16 +01:00
commit e14eb2d8fd
31193 changed files with 3555714 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
<?php
namespace Drupal\farm_input\Plugin\Log\LogType;
use Drupal\farm_entity\Plugin\Log\LogType\FarmLogType;
/**
* Provides the input log type.
*
* @LogType(
* id = "input",
* label = @Translation("Input"),
* )
*/
class Input extends FarmLogType {
/**
* {@inheritdoc}
*/
public function buildFieldDefinitions() {
$fields = parent::buildFieldDefinitions();
// Lot number.
$options = [
'type' => 'string',
'label' => $this->t('Lot number'),
'description' => $this->t('If this harvest is part of a batch or lot, enter the lot number here.'),
'weight' => [
'form' => -45,
'view' => -45,
],
];
$fields['lot_number'] = $this->farmFieldFactory->bundleFieldDefinition($options);
// Method.
$options = [
'type' => 'string',
'label' => $this->t('Method'),
'description' => $this->t('How was this input applied?'),
'weight' => [
'form' => -30,
'view' => -30,
],
];
$fields['method'] = $this->farmFieldFactory->bundleFieldDefinition($options);
// Purchase date.
$options = [
'type' => 'timestamp',
'label' => $this->t('Purchase date'),
'description' => $this->t('When was this input purchased (if applicable)?'),
'weight' => [
'form' => -35,
'view' => -35,
],
];
$fields['purchase_date'] = $this->farmFieldFactory->bundleFieldDefinition($options);
// Source.
$options = [
'type' => 'string',
'label' => $this->t('Source'),
'description' => $this->t('Where was this input obtained? Who manufactured it?'),
'weight' => [
'form' => -40,
'view' => -40,
],
];
$fields['source'] = $this->farmFieldFactory->bundleFieldDefinition($options);
return $fields;
}
}

View File

@@ -0,0 +1,71 @@
<?php
namespace Drupal\farm_input\Plugin\views\filter;
use Drupal\Core\Database\Database;
use Drupal\Core\Form\FormStateInterface;
use Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid;
/**
* Filter handler for log quantity material type terms.
*
* @ViewsFilter("log_quantity_material_type")
*/
class LogQuantityMaterialType extends TaxonomyIndexTid {
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
// Hard code the material_type vocabulary.
$options['vid'] = ['default' => 'material_type'];
return $options;
}
/**
* {@inheritdoc}
*/
public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildExtraOptionsForm($form, $form_state);
// Remove the vocabulary form element, use the hard coded default.
unset($form['vid']);
}
/**
* {@inheritdoc}
*/
public function query() {
// Bail if there are no filter values.
if (count($this->value) == 0) {
return;
}
elseif (count($this->value) == 1) {
// Sometimes $this->value is an array with a single element so convert it.
// @see TaxonomyIndexTidDepth::query().
if (is_array($this->value)) {
$this->value = current($this->value);
}
$operator = '=';
}
else {
$operator = 'IN';
}
// Build a subquery to find logs that reference a quantity with the
// specified material type.
$subquery = Database::getConnection()->select('log', 'l');
$subquery->addField('l', 'id');
$subquery->innerJoin('log__quantity', 'lq', 'l.id = lq.entity_id');
$subquery->innerJoin('quantity__material_type', 'qmt', 'lq.quantity_target_id = qmt.entity_id AND lq.quantity_target_revision_id = qmt.revision_id');
$subquery->condition('qmt.material_type_target_id', $this->value, $operator);
// Get the table alias for log_field_data.
$this->tableAlias = $this->query->ensureTable($this->view->storage->get('base_table'));
// Use the subquery in a condition on the views query to prevent duplicates.
$this->query->addWhere($this->options['group'], "$this->tableAlias.id", $subquery, 'IN');
}
}