method as_array() doesn't work - orm

I'm using idiorm as an ORM library and the method as_array() doesn't work this is my code I get 2 errors
1- $market = $market->as_array();
PHP Fatal error: Call to a member function as_array() on a non-object
2- ->as_array();
PHP Fatal error: Call to a member function as_array() on a non-object
My code:
function ($market = 'affiliate', $category = array('all')) use ($app) {
$market = \ORM::for_table('category')
->where('alias', $market)
->find_one();
$market = $market->as_array();
$category = #end($category);
if ($category != 'all') {
$category = \ORM::for_table('category')
->where('alias', $category)
->where_gt('category_id', 0)
->find_one()
->as_array();
$items = \ORM::for_table('item')
->select('item.*')
->select('category.name', 'category_name')
->join('category', 'category.id = item.category_id')
->where('item.category_id', $category['id']);

According to the Idiorm docs:
Any method chain that ends in find_one() will return either a single instance of the ORM class representing the database row you requested, or false if no matching record was found.
You should check to see if your query has returned any rows before calling as_array().
For example:
$market = \ORM::for_table('category')
->where('alias', $market)
->find_one();
if($market != false)
{
$market = $market->as_array();
}
If this still gives an error then you may not have initialised Idiorm properly.

Related

Kreait : verifySessionCookie() not found

I try to verify a session cookie from the $sessionCookieString = $auth->createSessionCookie($idToken, $oneWeek); which work normally.
But report say that the function is not found.
"Call to undefined method Kreait\Firebase\Auth::verifySessionCookie()"
Didn't understand why.
i have the latest version install.
--- Portion of code below ---
use Kreait\Firebase\Factory;
use Kreait\Firebase\Contract\Auth;
use Kreait\Firebase\Auth\UserQuery;
use Google\Cloud\Firestore\FirestoreClient;
use Kreait\Firebase\Auth\CreateSessionCookie\FailedToCreateSessionCookie;
public function doLogin() {
$factory = (new Factory)->withServiceAccount($this->ekonysJson );
$auth = $factory->createAuth();
$this->auth = $auth;
//print_r($auth);
$signInResult = $auth->signInWithEmailAndPassword("email#dot", "password");
$idToken = $signInResult->idToken();
`print_r($signInResult->refreshToken());`
$oneWeek = new \DateInterval('P7D');
$sessionCookieString = $auth->createSessionCookie($idToken, $oneWeek);
$verifiedSessionCookie = $auth->verifySessionCookie($sessionCookieString)
}
refer to doc https://firebase-php.readthedocs.io/en/stable/authentication.html#session-cookies
if you have any idea.... thanks
Solution for this problem

karate.match is throwing a TypeError when validating against a string

I am doing some UI automation using Karate. In this particular scenario, the goal is to navigate to a page that has a table with pagination. If there is a "next page" button, to click it, and to verify the pagination changes as expected (pagination will always return either an 8 or a 9).
I have the following code:
* def getPagination =
"""
function(){
var nameVal = []
var nextPageBtn = false
do {
nextPageBtn = driver.exists('skipToNext a');
if (nextPageBtn {
driver.click('skipToNext a');
var getPagination = (driver.text(li[class='active'] a)).trim()
karate.log("The current page value is:", getPagination)
karate.match (getPagination == '8' || '9')
var getNameVal = driver.scriptAll('#names', '_.textContent')
nameVal.push(getNameVal)
}
} while (nextPageBtn)
return(nameVal);
}
I am getting the following error on the match:
org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (match) on com.intuit.karate.core.ScenarioBridge#5d32d8f failed due to: no applicable overload found (overloads: [Method[public java.lang.Object com.intuit.karate.core.ScenarioBridge.match(java.lang.String)], Method[public java.lang.Object com.intuit.karate.core.ScenarioBridge.match(java.lang.Object,java.lang.Object)]], arguments: [true (Boolean)])
- <js>.:anonymous(Unnamed:17)
Any ideas?

Prestashop 1.7.7.5: FrameworkBundleAdminController: $this->module->getPathUri() returns an error

In my admin module's controller's listMappingsAction action, I want to show a Vue.JS template, passing two variables that need to call $this->module->getPathUri() to be assigned a value:
<?php
namespace XYZ\Controller;
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
use PrestaShopBundle\Security\Annotation\AdminSecurity;
class AutomatizedMappingController extends FrameworkBundleAdminController
{
/**
* #AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message="Access denied.")
*/
function listMappingsAction() {
return $this->render('#Modules/XYZ/views/templates/admin/app.html.twig', [
'XYZ' => [
'pathApp' => $this->module->getPathUri() . 'views/js/app.js',
'chunkVendor' => $this->module->getPathUri() . 'views/js/chunk-vendors.js',
]
]);
}
}
The use of $this->module->getPathUri() results in this error being displayed:
Attempted to call an undefined method named "getPathUri" of class "XYZ\Controller\AutomatizedMappingController". [Symfony\Component\Debug\Exception\UndefinedMethodException 0]
What could I call to make it work? The docs don't mention this use case... https://devdocs.prestashop.com/1.7/modules/concepts/templating/vuejs/faq/#how-to-send-data-from-symfony-controller-to-vuejs
First of all you need to know there is a difference between a module and a admin-controller. You cannot call $this->module->getPathUri() because your not using a extends ModuleAdminController, extends ModuleFrontController, extends Module ...
So you can only call $this->module if your actually using files inside a module.
Since i don't know which path you are trying to go to ill pass you a few variables which you might be able to use.
$this->module->name = crezzurmodulename
$this->module->getLocalPath() = C:\yourstore/modules/crezzurmodulename/
$this->module->getPathUri() = /yourstore/modules/crezzurmodulename/
_MODULE_DIR_ = /yourstore/modules/
_PS_MODULE_DIR_ = C:\yourstore/modules/
__DIR__ = C:\yourstore\modules\crezzurmodulename\controllers\front
_PS_CAT_IMG_DIR_ = C:\yourstore/img/c/
_PS_PROD_IMG_DIR_ = C:\yourstore/img/p/
_PS_TMP_IMG_DIR_ = C:\yourstore/img/tmp/
_PS_ROOT_DIR_ = C:\yourstore
_PS_CACHE_DIR_ = C:\yourstore/var/cache/dev\
_PS_BASE_URL_ = http://127.0.0.1
__PS_BASE_URI__ = /yourstore/
_PS_TRANSLATIONS_DIR_ = C:\yourstore/translations/
_PS_BASE_URL_SSL_ = http://127.0.0.1 or https://127.0.0.1
_PS_DOWNLOAD_DIR_ = C:\yourstore/download/
_PS_COL_IMG_DIR_ = C:\yourstore/img/co/
_PS_SHIP_IMG_DIR_ = C:\yourstore/img/s/
_PS_UPLOAD_DIR_ = C:\yourstore/upload/

Terraform 0.12.5 | Bigquery table resource doesn't support external data configuration block

I'm creating a module to make easy to provision a BigQuery table in GCP.
My module is working, but now I'm trying to add the option to create the table based in external data, like a GCS bucket.
In the doc (https://www.terraform.io/docs/providers/google/r/bigquery_table.html#external_data_configuration) are saying this configuration is supported, but I get only this error:
Acquiring state lock. This may take a few moments...
Error: Unsupported block type
on ../../modules/bq_table/main.tf line 24, in resource "google_bigquery_table" "default":
24: external_data_configuration {
Blocks of type "external_data_configuration" are not expected here.
Im using the last Terraform version (0.12.5) and google provider v2.10.0 in Mac OS.
Here is my module code in HCL2:
resource "google_bigquery_table" "default" {
dataset_id = "${terraform.workspace}_${var.bq_dataset_id}"
table_id = "${terraform.workspace}_${var.bq_table_id}"
project = (var.project_id != "" ? var.project_id : null)
description = (var.bq_table_description != "" ? var.project_id : null)
expiration_time = (var.bq_table_expiration_time != null ? var.project_id : null)
friendly_name = (var.bq_table_name != "" ? var.project_id : null)
dynamic "external_data_configuration" {
for_each = var.bq_table_external_data_configuration
content {
autodetect = true
source_format = "NEWLINE_DELIMITED_JSON"
source_uris = [external_data_configuration.value]
}
}
time_partitioning {
type = "DAY"
field = var.bq_table_partition_field
}
labels = var.bq_table_labels
schema = (var.bq_table_schema != "" ? var.bq_table_schema : null)
dynamic "view" {
for_each = (var.bq_table_view_query != "" ? {query = var.bq_table_view_query} : {})
content {
query = view.value
}
}
depends_on = ["null_resource.depends_on"]
}
Above im using Dynamic blocks, but tried to use normally and the error is the same.
The for_each property inside your dynamic block expects an array value. Try wrapping the input variable in an array:
dynamic "external_data_configuration" {
for_each = var.bq_table_external_data_configuration ? [var.bq_table_external_data_configuration] : []
content {
autodetect = true
source_format = "NEWLINE_DELIMITED_JSON"
source_uris = [external_data_configuration.value]
}
}
Conditional blocks are still a bit of a hassle even after Terraform 0.12; read here for more.

Phalcon mongodb cannot update

I can't update a document with Phalcon MongoCollection from Incubator 3.3
I don't get any error after save() but data are not updated.
My code is:
$category = CategoryModel::findById($id);
$category->title = 'uno';
$category->save();
I have also tried with incubator 3.4 and 3.2
I don't know why but after calling the singleton:
MyModel::findById($id)
...the source collection I defined on the model constructor changes from 'myCustomCollection' to 'my_model'
I fixed it by adding some temporary code inside the _getResultSet method from app/vendor/phalcon/incubator/Library/Phalcon/Mvc/MongoCollection.php (Line 310)
$cursor->setTypeMap(['root' => get_class($base), 'document' => 'array']);
if (true === $unique) {
/**
* Looking for only the first result.
*/
$output = current($cursor->toArray());
$output->setSource($base->getSource());
return $output;
}