T
T
Trionik2021-06-28 08:26:10
1C-Bitrix
Trionik, 2021-06-28 08:26:10

How to define that the class was connected?

This error pops up Placed the mailing
Class 'Bitrix\Sender\MailingTable' not found (0)

class in the /local/php_interface/lib folder an excerpt from the mailing class

<?php
/**
 * Bitrix Framework
 * @package bitrix
 * @subpackage sender
 * @copyright 2001-2012 Bitrix
 */
namespace Bitrix\Sender;

use Bitrix\Main\DB\SqlExpression;
use Bitrix\Main\Entity;
use Bitrix\Main\Localization\Loc;
use Bitrix\Main\Type as MainType;

use Bitrix\Sender\Internals\Model;

Loc::loadMessages(__FILE__);

class MailingTable extends Entity\DataManager
{
  /**
   * @return string
   */
  public static function getTableName()
  {
    return 'b_sender_mailing';
  }

Put the class in the autoloader
<?	
Bitrix\Main\Loader::registerAutoLoadClasses(null, [
    'Bitrix\Sender\Subscription' => '/local/php_interface/lib/subscription.php'
]);

Bitrix\Main\Loader::registerAutoLoadClasses(null, [
    'Bitrix\Sender\mailing' => '/local/php_interface/lib/mailing.php'
]);
?>

connected the autoloader in the init.php file
require_once( $_SERVER['DOCUMENT_ROOT'] . '/local/php_interface/autoload.php');


This code still throws an error
<?
namespace Newssend;

use  Bitrix\Sender\mailing;
  
class class_news extends \CBitrixComponent
  {	
  function OnAfterIBlockElementAddHandler(&$arFields)
    {
    $arrSITE="s1";	
  
    $data = array( 
        'order' => array ("ID"=>"ASC"),
        'filter' => array("RUBRIC"=>$aPostRub, 
        "CONFIRMED"=>"Y", 
        "ACTIVE"=>"Y",
        "FORMAT"=>$post_arr["SUBSCR_FORMAT"], 
        "EMAIL"=>$post_arr["EMAIL_FILTER"], 
        "RUBRIC"=>array("CONFIRMED"=>"Y", 
        "ACTIVE"=>"Y",
        "ID"=>"1"))
        );				
        $subscr = \Bitrix\Sender\Subscription::getList($data);
    }
  } 
?>

Error
Class 'Bitrix\Sender\MailingTable' not found (0)

1. How do I know that this class is connected to me?
2. I need to write something in my class to connect this class or
use Bitrix\Sender\mailing;

is this a class connection?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Aricus, 2021-06-28
@Aricus

'Bitrix\Sender\mailing'

class MailingTable

You are connecting mailing and you are expecting MailingTable to be connected.
1. If an error does not pop up when using the class, it means that you have connected.
2. I'm not sure here: probably, this is automatically registered in the CMS. But check. Only
use Bitrix\Sender\MailingTable;

S
Sergey, 2021-06-29
@Firsov36


Placed the mailing class in the /local/php_interface/lib folder
excerpt from the mailing class

You write that you have connected the mailing class, but there is no such class in the class code, but there is a MailingTable
class MailingTable extends Entity\DataManager
By the way, there is the same class from Bitrix. Are you trying to rewrite the standard Bitrix class? Classes start with a capital letter.
If you already write your own class, then use your own namespace, why fence a garden in someone else's field?
Well, answering the question: "How to determine that the class is connected?"
PHP has a method to check if a class exists
if (class_exists('MyClass')) {
    $myclass = new MyClass();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question